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.
initWithObjects, passingnilas a parameter signals that that is the last object passed in. On a side note, I would recommend using anNSURLinstead of anNSStringfor your picFile parameter, as NSURLs are more efficient when storing path data. Check out this question for more info on NSURLs and NSStrings: <stackoverflow.com/questions/7769219/…>