开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜