我運行一個後臺線程來從Web服務獲取數據。的iOS5 BAD_EXCESS僅在設備
獲取所需用於創建網址我使用這個方法的設置:
+(Settings *)getSettings
{
Settings *settings = [[Settings alloc] init];
NSString *path = [NSString stringWithFormat:@"Documents/Settings"];
NSString *settingsPath = [NSHomeDirectory() stringByAppendingPathComponent:path];
NSFileManager *fileMgr = [NSFileManager defaultManager];
if ([fileMgr fileExistsAtPath:settingsPath]) {
NSDictionary *settingsDictionary = [NSDictionary dictionaryWithContentsOfFile:settingsPath];
settings.username = [settingsDictionary objectForKey:@"username"];
settings.module = [settingsDictionary objectForKey:@"module"];
settings.websiteUrl = [settingsDictionary objectForKey:@"websiteUrl"];
}else
{
settings.username = @"";
settings.module = @"";
settings.websiteUrl = @"";
}
NSLog(@"Settings = u:%@ m:%@ w:%@",settings.username,settings.module,settings.websiteUrl);
return settings;
}
這個工程在調試器正常,但當我在設備上運行它,我得到BAD_EXCESS上的NSLog或任何類別試圖與警告使用數據:
警告:試圖創建與塊不是在幀USE_BLOCK_IN_FRAME變量。
這是代碼在設備上工作的罰款,如果我通過代碼。
任何想法?
編輯: 回溯 -
#0 0x37a97eda in objc_retain()
#1 0x37aa4be4 in objc_retainAutoreleasedReturnValue()
#2 0x0000f84a in +[SettingData getSettings] (self=0x175e4, _cmd=0x11af9) at /Users/Jono/Dropbox/Uni/iOS5/Feedback At Tees/Feedback At Tees/SettingData.m:49
#3 0x0000fa86 in -[DataManager init] (self=0x3509e0, _cmd=0x30fd9f96) at /Users/Jono/Dropbox/Uni/iOS5/Feedback At Tees/Feedback At Tees/DataManager.m:19
#4 0x00003b46 in __35-[MasterViewController viewDidLoad]_block_invoke_0 (.block_descriptor=0x185f40) at /Users/Jono/Dropbox/Uni/iOS5/Feedback At Tees/Feedback At Tees/MasterViewController.m:70
#5 0x30b08d54 in _dispatch_call_block_and_release()
#6 0x30b0b896 in _dispatch_worker_thread2()
#7 0x37a0e1ce in _pthread_wqthread()
#8 0x37a0e0a4 in start_wqthread()
我試圖加入以下的設置init方法,如果我步驟通過它是確定如果我不崩潰在第二NSLog的與所述錯誤:消息發送以釋放實例0x160d60
-(id)init
{
if ((self=[super init]))
{
NSString *path = [NSString stringWithFormat:@"Documents/Settings"];
NSString *settingsPath = [NSHomeDirectory() stringByAppendingPathComponent:path];
NSFileManager *fileMgr = [NSFileManager defaultManager];
if ([fileMgr fileExistsAtPath:settingsPath])
{
NSDictionary *settingsDictionary = [NSDictionary dictionaryWithContentsOfFile:settingsPath];
self.username = [settingsDictionary objectForKey:@"username"];
self.module = [settingsDictionary objectForKey:@"module"];
self.websiteUrl = [settingsDictionary objectForKey:@"websiteUrl"];
NSLog(@"Settings = u:%@ m:%@ w:%@",self.username,self.module,self.websiteUrl);
}
else
{
self.username = @"";
self.module = @"";
self.websiteUrl = @"";
}
}
NSLog(@"Settings = u:%@ m:%@ w:%@",self.username,self.module,self.websiteUrl);
return self;
}
截圖: http://postimage.org/image/4vw6uq7pp/
BAD_EXCESS或EXC_BAD_ACCESS? – 2012-04-17 16:12:41
只是檢查是EXC_BAD_ACCESS – Jonoh89 2012-04-17 16:25:41
具有運行分析? – 2012-04-17 16:27:50