Warning Pass-by-Value?
I am fairly new to Objective-C and whilst running the Clang static analyser this section of code gave me the following error
warning: Pass-by-value argument in message expressi开发者_如何转开发on is undefined
[artistCollection removeObject:removeArtist];
Can anyone cast any light on this warning for me?
case 6:
NSLog(@"(*) - First Name:");
scanf("%s", userFirName);
objFirName = [[NSString alloc] initWithUTF8String:userFirName];
for(eachArtist in artistCollection) {
if([[eachArtist firName] isEqualToString: objFirName]) {
removeArtist = eachArtist;
}
}
[artistCollection removeObject:removeArtist];
[objFirName release], objFirName = nil;
break;
gary
If you never get a match on that if
inside your loop (because userFirName
isn't in your collection), removeArtist
will never get assigned a value. Assign it a value before starting the loop (nil
, probably), and you should be fine.
精彩评论