objective c - If Statement not Running -



objective c - If Statement not Running -

i new objective c , cocoa, have spent lot of time c++, , have never run across issue before.

my application needs identify mounted disk name. here code:

//this code run whenever new disk mounted computer -(void) scanforkindle:(nsnotification *) notification { nsmutablearray *mounteddisks = [[nsmutablearray alloc] init]; mounteddisks = [workspace mountedremovablemedia]; nsmutablearray *ebookdevices = [[nsmutablearray alloc] init]; nsdictionary *fileattributes = [[nsdictionary alloc] init]; int currentdisk; (currentdisk = 0; currentdisk < [mounteddisks count]; currentdisk++) { nslog(@"name: %@", [mounteddisks objectatindex:currentdisk]); if ([mounteddisks objectatindex:currentdisk] == @"/volumes/kindle") { nslog(@"kindle has been identified"); } } }

i have gotten work if statement in loop. wont run. ideas why? sure simple fix, cannot figure out life of me.

any help appreciated!

that's because making pointer comparing between 2 different instances of nsstrings.

do instead -

if ([[mounteddisks objectatindex:currentdisk] isequaltostring:@"/volumes/kindle"]) { nslog(@"kindle has been identified"); }

objective-c cocoa

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -