1

我正在写一个FTP下载系统,列表功能:

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

我在服务器上看到我的文件:

{
    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;
},

接下来我想做的是:

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
        }


    }

*我的问题是比较错误,我怎么写才能工作?

4

2 回答 2

1

[file objectForKey:]不会返回int. 它返回一个NSNumber(又名CFNumberRef)。

演示:

NSNumber * n = [file objectForKey:(id)kCFFTPResourceType];
const int i = n.intValue;
if (8 == i) {
  [filesList addObject:[file objectForKey:(id)kCFFTPResourceName]];
}
于 2012-11-08T09:13:54.160 回答
0

当需要 kCFFTPResourceType 详细信息时,这可能很有用。

kCFFTPResourceType 详细信息

于 2014-09-20T13:08:23.220 回答