I’ve encountered a weird issue thats causing me quite the headache. I am initializing an NSArray object using initWithObjects. I’m passing in 7 objects but immediately afterwords, if I log the count of the array, I only have a count of 3. Has anyone else seen this? I’ve used this method countless times with no problem before and I can’t see what I’m doing wrong. The code is below:
-(DMORecipe *) saveRecipe:(NSNumber *)recipeID recipeTitle:(NSString *)title recipeDescription:(NSString *)description pictureFile:(NSString *)picFile preparationTime:(NSString *)prepTime cookingTime:(NSString *)cookTime ovenTemperature:(NSString *)ovenTemp {
NSArray *newRow = [[NSArray alloc] initWithObjects:recipeID,title, description, picFile, prepTime, cookTime, ovenTemp, nil];
NSLog(@"Before update, the number of args is %i", [newRow count]);
}
Do I have a type-o somewhere that I’m missing? You can see I’m passing in 7 objects to the array initializer but the NSLog method shows [newRow count] = 3.
If any of the object passed in is
nil, the rest of the argument will be ignored.In this case, it seems that
picFileisnil.