//current array
NSMutableArray *arrayCurrentArray;
// 인덱스 indexCurrentPage = 1;
배열은 다음과 같이 실행시에 초기화 할 필요가 :
arrayCurrentArray =
[[NSMutableArray alloc]
initWithArray:arrayBrotherPirateEnglish
copyItems:YES];
이 배열을 초기화하는 방법입니다
indexCurrentPage++;
if(indexCurrentPage <= [arrayCurrentArray count]) {
//next page to play
strFileName = [arrayCurrentArray objectAtIndex:indexCurrentPage];
NSLog(@"next page filename %s ", strFileName);
//set the player
NSURL *url = [NSURL URLWithString:strFileName];
[player setContentURL:url];
//play
[player play];
}
: 다음과 같은 코드를
arrayBrotherPirateEnglish = [NSArray arrayWithObjects:@"OBTP English full with text", @"OBTP English p1", @"OBTP English p2", @"OBTP English p3", @"OBTP English p4", @"OBTP English p5", @"OBTP English p6",
@"OBTP English p7", @"OBTP English p8", @"OBTP English p9", @"OBTP English p10",
@"OBTP English p11",
nil];
내 문제는 배열 내의 항목에 액세스 할 수 없다는 것입니다. 어떤 통찰력은 감사
2010-07-26 12:57:18.888 BookReaderJuly23[49638:207] next page filename ‡ûú»
2010-07-26 12:57:18.890 BookReaderJuly23[49638:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:isDirectory:]: nil string parameter'
2010-07-26 12:57:18.892 BookReaderJuly23[49638:207] Stack: (
:
이
내가 점점 오전 오류입니다.
에 부합하지 않는이 오류입니다 26 13:43:47.154 BookReaderJuly23 [50,904 : 207] *** 의한 캐치되지 않는 예외 'NSInvalidArgumentException'응용 프로그램 종료, 이유 : - 이 선행하는 코드 "*** [NSCFString objectAtIndex :] 미정 선택기 인스턴스 0x5533de0 전송 ' strFileName = [arrayBrotherPirateEnglish objectAtIndex : 2]; \t \t \t \t NSLog (@ "다음 페이지 파일명 % @", strFileName); – butchcowboy
즉, NSArray가 아닌 NSString 객체에 objectAtIndex : 메시지를 보냅니다. 이것은 NSArray 변수를 NSString에 재 할당했거나 메모리 관리 문제 (어레이를 너무 일찍 풀어 놓는 등)를 의미 할 수 있습니다. 좀비 도구를 사용하면 실제로 메모리 문제가있는 경우 추적 할 수 있습니다. 하지만 몇 가지 기본 원칙에 어려움을 겪고있는 것처럼 보입니다. 따라서 누군가가 일반적인 오류를 찾는 데 도움이되는 전체 프로그램을보다 경험있게 보길 원할 수 있습니다. –