我正在创建一个需要创建目录才能下载某些文件的应用。当我打电话
[[NSFileManager defaultManager] createDirectoryAtPath:
[[self.searchURL theDownloadLocation] stringByStandardizingPath]
withIntermediateDirectories:YES attributes:nil error:nil];
内
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
它工作正常。我有一个按钮,应该开始下载。我已将它放在xib文件中,它可以做任何其他事情,所以我知道按钮有效。同样,如果我在NSFileManager
内调用applicationDidFinishLaunching
方法,但在按下按钮时调用的其他方法内,则创建目录没有问题。它与(lldb)
消息崩溃。
传递的参数完全相同,我甚至NSLog
在按钮方法中[[self.searchURL theDownloadLocation] stringByStandardizingPath]
,它肯定是NSString
,所以按下按钮时会记录。我错过了什么?
我有时收到错误消息:
2013-02-12 19:33:04.404 dArt[2351:303] -[NSISRestrictedToNonNegativeVariableToBeMinimized
stringByStandardizingPath]: unrecognized selector sent to instance 0x100528ba0
2013-02-12 19:33:04.405 dArt[2351:303] -[NSISRestrictedToNonNegativeVariableToBeMinimized
stringByStandardizingPath]: unrecognized selector sent to instance 0x100528ba0
2013-02-12 19:33:04.408 dArt[2351:303] ( 0 CoreFoundation 0x00007fff862c40a6 __exceptionPreprocess + 198 1 libobjc.A.dylib 0x00007fff8d4e53f0 objc_exception_throw + 43 2 CoreFoundation 0x00007fff8635a6ea -[NSObject(NSObject) doesNotRecognizeSelector:] + 186 3 CoreFoundation 0x00007fff862b25ce ___forwarding___ + 414 4 CoreFoundation 0x00007fff862b23b8 _CF_forwarding_prep_0 + 232 5 dArt 0x000000010000248d -[AppDelegate searchTheArt:] + 141 6 AppKit 0x00007fff8a91ea59 -[NSApplication sendAction:to:from:] + 342 7 AppKit 0x00007fff8a91e8b7 -[NSControl sendAction:to:] + 85 8 AppKit 0x00007fff8a91e7eb -[NSCell _sendActionFrom:] + 138 9 AppKit 0x00007fff8a91ccd3 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1855 10 AppKit 0x00007fff8a91c521 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504 11 AppKit 0x00007fff8a91bc9c -[NSControl mouseDown:] + 820 12 AppKit 0x00007fff8a91360e -[NSWindow sendEvent:] + 6853 13 AppKit 0x00007fff8a90f744 -[NSApplication sendEvent:] + 5761 14 AppKit 0x00007fff8a8252fa -[NSApplication run] + 636 15 AppKit 0x00007fff8a7c9cb6 NSApplicationMain + 869 16 dArt 0x00000001000016b2 main + 34 17 libdyld.dylib 0x00007fff8b36b7e1 start + 0 )
答案 0 :(得分:1)
我的问题已在其他地方得到解答。我只需要将(copy)
限定符添加到theDownloadLocation
属性。
赞@property (copy) NSString *theDownloadLocation;