기본적으로 문제는 제목이 말하는 것과 정확히 같습니다.iPhone : [NSBundle mainbundle] 호출은 시뮬레이터가 아닌 기기에서 충돌 함
내 응용 프로그램이 충돌없이 시뮬레이터에서 원활하게 작동합니다. 사실, 이전 버전은 앱 스토어에 있습니다. 나는 여기저기서 사소한 변화를 일으켰고 갑자기 아주 이상한 곳에서 충돌하기 시작했다.
나는 ... 그것을 반환 어느 시점에서, 그러나, NSBundle mainBundle]
에 처음 몇 통화가 완전히 정상으로 expected-있는 등 PLIST 파일, 이미지에 액세스하는 코드의 다양한 장소에서 [NSBundle mainBundle] resourcepath]
를 사용
-[NSBundle < null selector>]: unrecognized selector sent to instance 0x10a0e0
... 장치에서 충돌합니다. 여기에 정확한 코드입니다 : 그 전화가 정말 문제가있는 경우
-(void) setImageName:(NSString *)s
{
[imageName release];
imageName = [s copy];
NSLog(@"last line before crash");
NSString *imagePath =[[NSBundle mainBundle] resourcePath];
NSLog(@"Why would it crash before here???");
imagePath = [imagePath stringByAppendingString:imageName];
imageUI = [[UIImage alloc] initWithContentsOfFile:imagePath];
[self setNeedsDisplay];
}
확인하려면, 내가 이제까지 처음 몇 통화가 I로 완전히 정상이었다 (프로젝트에 [NSBundle mainbundle]
에 전화를 처음의 문자열로 resourcePath
저장 위에서 언급 한) 그 resourcePath
문자열을 사방에 필요로했다 [NSbundle mainbundle]와 voila! 아무런 충돌/누출, 아무것도 ...
나는 완전히 혼란스러워. 왜 그 장치에 내 응용 프로그램이 충돌하지만 시뮬레이터가 아닌가요?
편집 :
NSArray *array = [NSBundle allBundles];
NSBundle *bundle = [array objectAtIndex:0];
NSString *imagePath = [bundle bundlePath];
사용 ... ... 대신 [[NSBundle mainBundle] resourcePath]
도 작동합니다. 나는 어떻게 든이 특별한 통화에만 영향을주는 것을하고 있다고 생각합니다.
편집 2은 : 여기에서 중단 점을 설정 역 추적하다 - [NSObject의 doesNotRecognizeSelector :]
#0 0x30e27b98 in -[NSObject doesNotRecognizeSelector:]
#1 0x30dacb18 in ___forwarding___
#2 0x30da3840 in __forwarding_prep_0___
#3 0x0000bcfe in -[CustomTableViewCell setImageName:] at CustomTableViewCell.m:93
#4 0x0000499e in -[RootTableViewController tableView:willDisplayCell:forRowAtIndexPath:] at RootTableViewController.m:469
#5 0x3364d5d0 in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:]
#6 0x3364cde0 in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:]
#7 0x335f832c in -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow]
#8 0x335f6514 in -[UITableView layoutSubviews]
#9 0x335f22d8 in -[UIView(CALayerDelegate) _layoutSublayersOfLayer:]
#10 0x32bac1c0 in -[CALayer layoutSublayers]
#11 0x32babedc in CALayerLayoutIfNeeded
#12 0x32bab844 in CA::Context::commit_transaction
#13 0x32bab474 in CA::Transaction::commit
#14 0x32bb35dc in CA::Transaction::observer_callback
#15 0x30da1830 in __CFRunLoopDoObservers
#16 0x30de9346 in CFRunLoopRunSpecific
#17 0x30de8c1e in CFRunLoopRunInMode
#18 0x332e7374 in GSEventRunModal
#19 0x335adc30 in -[UIApplication _run]
#20 0x335ac230 in UIApplicationMain
... 어디 # 3 - CustomTableViewCell.m : 93이되어있는 NSString * = IMAGEPATH [[NSBundle mainBundle] resourcePath]; 위에서 게시 한 코드 부분에서
당신은 어디에서나 [NSBundle mainBundle]'에서 반환 된 객체를 공개하고 있습니까? – kubi
'- [NSObject doesNotRecognizeSelector :]'에 중단 점을 설정하고 백 트레이스를 게시하십시오. – Chuck
@chuck - Thx하지만 중단 점을 어디에 놓아야하는지 이해하지 못했습니다. –