开发者

Xcode keeps telling me my usage of NSDirectoryEnumerator is wrong.

I am trying to instantiate an NSDirectoryEnumerator from a NSFileManager like this

NSDirectoryEnumerator *enum = [fm enumeratorAtURL:*url includingPropertiesForKeys:nil options:nil errorHandler:nil];

and Xcode keeps coming with an error message that even after reading the complete FileManager and DirectoryManager Documentation doesn't make any sense to me:

E开发者_高级运维xpected identifier or '('

Do I have to import anything else than Core Foundation to use NSDirectoryEnumerator or is there some special trick to the usage syntax that I am missing?

// edit:

url is of course a valid NSURL. Just in case this might come up.


In C and, by extension, Objective-C, enum is a keyword. Change the variable name.

Also, you need to remove the asterisk, unless it's a pointer to NSURL * (i.e. NSURL **) as commented by @WTP:

NSDirectoryEnumerator *enum = [fm enumeratorAtURL:*url includingPropertiesForKeys:nil options:0 errorHandler:nil];
                                                  ^
                                              Right here!

And the options parameters should be 0, not nil as noted by @omz.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜