iosxcodecfstream

Compare kCFFTPResourceType to number


I am writing an FTP download system, the the listing function:

NSLog(@"%@", listDir.filesInfo);

I see my files on server:

{
    kCFFTPResourceGroup = group;
    kCFFTPResourceLink = "";
    kCFFTPResourceModDate = "2012-11-04 15:49:00 +0000";
    kCFFTPResourceMode = 511;
    kCFFTPResourceName = "eyeview__0000_sport_general.jpg";
    kCFFTPResourceOwner = owner;
    kCFFTPResourceSize = 169790;
    kCFFTPResourceType = 8;
},
    {
    kCFFTPResourceGroup = group;
    kCFFTPResourceLink = "";
    kCFFTPResourceModDate = "2012-11-04 15:49:00 +0000";
    kCFFTPResourceMode = 511;
    kCFFTPResourceName = "eyeview__0001_sport_reading.jpg";
    kCFFTPResourceOwner = owner;
    kCFFTPResourceSize = 224795;
    kCFFTPResourceType = 8;
},

The next thing I wish to do is:

for (NSDictionary *file in listDir.filesInfo)
    {
        NSLog(@"%@", [file objectForKey:(id)kCFFTPResourceName]); //Prints the file name

        if ([file objectForKey:(id)kCFFTPResourceType]==8) //*My problem
        {
            [filesList addObject:[file objectForKey:(id)kCFFTPResourceName]]; //Works perfectly in case outside the if function
        }


    }

*My problem is the comparison wrong, how can I write it to work?


Solution

  • [file objectForKey:] won't return an int. It returns an NSNumber (aka CFNumberRef).

    Demo:

    NSNumber * n = [file objectForKey:(id)kCFFTPResourceType];
    const int i = n.intValue;
    if (8 == i) {
      [filesList addObject:[file objectForKey:(id)kCFFTPResourceName]];
    }