2010-12-22 10 views
-2

배열의 초기화 다음 코드는 작동 ::배열 초기화

NSArray *array = [[NSArray alloc] initWithObjects:@"Toy Story 3",@"Inception",nil]; 
self.list = [array sortedArrayUsingSelector:@selector(compare:)]; 
    [array release]; 
[super viewDidLoad]; 

그러나 다음 코드 나던. 아이폰 시뮬레이터는 배열을보기 위해 사용했던 Table View를 스크롤하자마자 종료됩니다. (내가 빈 tableViewCells에 스크롤 후에 만)

NSBundle *bundle = [NSBundle mainBundle]; 
NSString *plistPath = [bundle pathForResource:@"MovieList" ofType:@"plist"]; 
NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:plistPath]; 
NSLog([array objectAtIndex:1]); 
self.list = [array sortedArrayUsingSelector:@selector(compare:)]; 
    [array release]; 
[super viewDidLoad]; 

이 데이브 마크에 의해 "아이폰 개발을 시작"책에 들어있는 예제 응용 프로그램이었다. 이 예제에서는 코드 내에서 배열을 초기화했지만 외부 파일에서 초기화하려고 시도했습니다.

콘솔 로그 ::

2010-12-22 20:57:43.772 Nav[2474:40b] WARNING: Using legacy cell layout due to delegate implementation of tableView:accessoryTypeForRowWithIndexPath: in <RootViewController: 0x9908870>. Please remove your implementation of this method and set the cell properties accessoryType and/or editingAccessoryType to move to the new cell layout behavior. This method will no longer be called in a future release. 
2010-12-22 20:58:12.480 Nav[2474:40b] WARNING: Using legacy cell layout due to delegate implementation of tableView:accessoryTypeForRowWithIndexPath: in <DisclosureButtonController: 0x9b32ab0>. Please remove your implementation of this method and set the cell properties accessoryType and/or editingAccessoryType to move to the new cell layout behavior. This method will no longer be called in a future release. 
2010-12-22 20:59:13.299 Nav[2474:40b] -[UIDeviceRGBColor length]: unrecognized selector sent to instance 0x9b3d900 
2010-12-22 20:59:13.301 Nav[2474:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIDeviceRGBColor length]: unrecognized selector sent to instance 0x9b3d900' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x00db2be9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x00f075c2 objc_exception_throw + 47 
    2 CoreFoundation      0x00db46fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x00d24366 ___forwarding___ + 966 
    4 CoreFoundation      0x00d23f22 _CF_forwarding_prep_0 + 50 
    5 UIKit        0x0051a9ca -[UITableViewCellLayoutManager layoutSubviewsOfCell:] + 3424 
    6 UIKit        0x00482e02 -[UITableViewCell layoutSubviews] + 95 
    7 QuartzCore       0x01c70451 -[CALayer layoutSublayers] + 181 
    8 QuartzCore       0x01c7017c CALayerLayoutIfNeeded + 220 
    9 QuartzCore       0x01c6937c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310 
    10 QuartzCore       0x01c690d0 _ZN2CA11Transaction6commitEv + 292 
    11 QuartzCore       0x01c997d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99 
    12 CoreFoundation      0x00d93fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27 
    13 CoreFoundation      0x00d290e7 __CFRunLoopDoObservers + 295 
    14 CoreFoundation      0x00cf1bd7 __CFRunLoopRun + 1575 
    15 CoreFoundation      0x00cf1240 CFRunLoopRunSpecific + 208 
    16 CoreFoundation      0x00cf1161 CFRunLoopRunInMode + 97 
    17 GraphicsServices     0x016e7268 GSEventRunModal + 217 
    18 GraphicsServices     0x016e732d GSEventRun + 115 
    19 UIKit        0x002ca42e UIApplicationMain + 1160 
    20 Nav         0x00002598 main + 102 
    21 Nav         0x00002529 start + 53 
) 
terminate called after throwing an instance of 'NSException' 

enter code here 
+2

로그에 나타나는 메시지뿐만 아니라 응용 프로그램이 충돌하는 행을 게시하십시오. –

답변

2

그것은이 디버거를위한 완벽한 작업처럼 소리 같지 않아? 첫 번째 줄에 중단 점을 설정하지 말고 단계별로 변수를 검사 할 때 예기치 않게 변수가 0 또는 범위를 벗어나는 것이 아닌지 확인하십시오. 의심의 여지없이 콘솔에 기록되는 오류에 관심을 기울여도 도움이 될 것입니다.

종료 된 행이나 로그 메시지를 언급하지 않았으므로 모든 사람이 얻을 수있는 구체적인 내용입니다.

+0

콘솔 로그를 추가했습니다. –

+1

좋아요 ... 그래서 어떤 라인이 실패합니까? 디버거를 사용하여 코드를 단계별로 실행 한 결과는 무엇입니까? 우리는 수정 구슬이 없기 때문에 손을 잡고 돈을 내지 않고 있습니다 : * 우리가 당신을 도울 수 있도록 도와줍니다 *. –

0

NSLog의 첫 번째 인수는 NSString이어야합니다. 전달중인 개체가 UIColor 클러스터의 일부인 것처럼 보입니다. 나는 당신이 변경 제안 :

NSLog(@"%@", [array objectAtIndex:1]); 

그래서 첫 번째 인수가 확실히 문자열이고 그냥 다음 인수 중 객체의 설명을 인쇄했다.