我正在编写一个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
}
}
*我的问题是比较错误,我怎么写它才能工作?
答案 0 :(得分: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]];
}
答案 1 :(得分:0)
当需要kCFFTPResourceType详细信息时,这可能很有用。