【发布时间】:2011-11-19 17:33:30
【问题描述】:
好的,所以有人告诉我推迟
-(id)init
我的代码的一部分,但不幸的是,在字符串有时间注册更改之前,它是 NSLogging 一个 NULL 值。
这是我的 id init 代码
- (id)init {
if (self = [super init]) {
CFStringRef aCFString = (CFStringRef)[appDelegate baseURL];
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), aCFString, NULL, NULL);
pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
NSLog(@"xSheetMusicViewController - %@",appDelegate.baseURL);
CFRelease(pdfURL);
}
return self;
}
这是控制台输出:
2011-09-18 09:52:22.275 SheetMuse[57499:b603] value - (null)
failed to find PDF header: `%PDF' not found.
2011-09-18 09:52:24.575 SheetMuse[57499:b603] xSheetMusicViewController - (null)
2011-09-18 09:52:24.581 SheetMuse[57499:b603] Application tried to push a nil view controller on target <UINavigationController: 0x4e5a910>.
2011-09-18 09:52:24.624 SheetMuse[57499:b603] value - mussette.pdf
2011-09-18 09:52:24.627 SheetMuse[57499:b603] Application tried to push a nil view controller on target <UINavigationController: 0x4cc1ba0>.
2011-09-18 09:52:24.628 SheetMuse[57499:b603] value - mussette.pdf
最初的 NULL 值来自应用程序启动,当它应该为空时(毕竟,为什么我在启动时需要字符串?)但随后它提到它“未能找到 PDF 标题”,这对于我。然后 xSheetMusicViewController 尝试获取字符串值,但它在启动时仍然为空。然后从
更新值- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
方法,这意味着我必须以某种方式延迟 -(id)init 方法,或者找到一种更快的方法来在 init 之前更新字符串的值。
谁能帮忙?
【问题讨论】:
-
为什么又问同样的问题?您之前的问题中存在适合您的问题的答案:stackoverflow.com/questions/7459339/…
-
不合适。戴维爵士以为我在使用服务器。虽然我很想插入一个异步调度并让它像雨一样正确,但我不能。所有文件都是本地文件。
标签: iphone objective-c ios ipad nsstring