2012-03-26 4 views
0

그래서 오전 데 문제는 내가 비디오 이런 식으로로드하려고하면내가 SIGABRT 받고 있어요 (목표 - C)

-(void) viewDidLoad 
{ 
MyManager *sharedManager = [MyManager sharedManager]; 
[super viewDidLoad]; 
NSString *tempName = sharedManager.vidName; 
NSLog(@"%@", tempName); 

//This is where the problem is being caused 
NSString *url = [[NSBundle mainBundle] pathForResource:tempName ofType:@"mp4"]; 
//This is where I'm getting the SIGABRT thrown 
MPMoviePlayerController* theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]]; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallBack:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; 
theMovie.scalingMode = MPMovieScalingModeAspectFit; 
[theMovie.view setFrame:self.view.bounds]; 
[self.view addSubview:theMovie.view]; 
[theMovie play]; 

} 

나는 SIGARBT을 얻고을 NSException으로 인해 코드에서 지정한 곳에서 throw됩니다. 그러나 단순히 문자열을 다음과 같이 작성하면

- (void)viewDidLoad 
{ 
MyManager *sharedManager = [MyManager sharedManager]; 
[super viewDidLoad]; 
NSString *tempName = sharedManager.vidName; 
NSLog(@"%@", tempName); 

//This is the line I changed 
NSString *url = [[NSBundle mainBundle] pathForResource:@"vid_name" ofType:@"mp4"]; 

MPMoviePlayerController* theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]]; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallBack:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; 
theMovie.scalingMode = MPMovieScalingModeAspectFit; 
[theMovie.view setFrame:self.view.bounds]; 
[self.view addSubview:theMovie.view]; 
[theMovie play]; 

} 

코드가 제대로 작동합니다. 문제는 무엇이 될 수 있습니까? NSLog tempName이 올바른 문자열을 보유하고 있는지 확인합니다. 또한 sharedManager.vidName은 NSMutableString입니다. 이것은 내 고위 프로젝트를 끝내고 졸업하는 대학에서 저를 붙들어 놓은 유일한 문제입니다. 그래서 어떤 도움도 크게 감사 할 것입니다. 고맙습니다.

2012-03-26 22:04:52.115 SeniorProject[20502:207] Barbell Incline Bench Press - Medium Grip 
2012-03-26 22:04:52.120 SeniorProject[20502:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter' 
*** Call stack at first throw: 
(
0 CoreFoundation      0x00fb15a9 __exceptionPreprocess + 185 
1 libobjc.A.dylib      0x01105313 objc_exception_throw + 44 
2 CoreFoundation      0x00f69ef8 +[NSException raise:format:arguments:] + 136 
3 CoreFoundation      0x00f69e6a +[NSException raise:format:] + 58 
4 Foundation       0x007e3ab6 -[NSURL(NSURL) initFileURLWithPath:] + 90 
5 Foundation       0x007e3a44 +[NSURL(NSURL) fileURLWithPath:] + 72 
6 SeniorProject      0x000105f4 -[Video viewDidLoad] + 420 
7 UIKit        0x000ef089 -[UIViewController view] + 179 
8 UIKit        0x000ed482 -[UIViewController contentScrollView] + 42 
9 UIKit        0x000fdf25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48 
10 UIKit        0x000fc555 -[UINavigationController _layoutViewController:] + 43 
11 UIKit        0x000fd870 -[UINavigationController _startTransition:fromViewController:toViewController:] + 524 
12 UIKit        0x000f832a -[UINavigationController _startDeferredTransitionIfNeeded] + 266 
13 UIKit        0x000ff562 -[UINavigationController pushViewController:transition:forceImmediate:] + 932 
14 UIKit        0x000f81c4 -[UINavigationController pushViewController:animated:] + 62 
15 SeniorProject      0x00005998 -[ExerciseList goToVideo:] + 328 
16 UIKit        0x0003f4fd -[UIApplication sendAction:to:from:forEvent:] + 119 
17 UIKit        0x000cf799 -[UIControl sendAction:to:forEvent:] + 67 
18 UIKit        0x000d1c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527 
19 UIKit        0x000d07d8 -[UIControl touchesEnded:withEvent:] + 458 
20 UIKit        0x00063ded -[UIWindow _sendTouchesForEvent:] + 567 
21 UIKit        0x00044c37 -[UIApplication sendEvent:] + 447 
22 UIKit        0x00049f2e _UIApplicationHandleEvent + 7576 
23 GraphicsServices     0x011ea992 PurpleEventCallback + 1550 
24 CoreFoundation      0x00f92944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
25 CoreFoundation      0x00ef2cf7 __CFRunLoopDoSource1 + 215 
26 CoreFoundation      0x00eeff83 __CFRunLoopRun + 979 
27 CoreFoundation      0x00eef840 CFRunLoopRunSpecific + 208 
28 CoreFoundation      0x00eef761 CFRunLoopRunInMode + 97 
29 GraphicsServices     0x011e91c4 GSEventRunModal + 217 
30 GraphicsServices     0x011e9289 GSEventRun + 115 
31 UIKit        0x0004dc93 UIApplicationMain + 1160 
32 SeniorProject      0x00001b39 main + 121 
33 SeniorProject      0x00001ab5 start + 53 
) 
terminate called after throwing an instance of 'NSException' 
+0

SIGABRT가 있으면 로그에 뭔가가 있습니다. 그걸 게시해라. – CodaFi

+0

@CodaFi : 지금 편집에 넣을 게요 –

답변

0

는 오류에서이 줄을 참조했다.

+0

혼란 스럽 습니다만, 두 번째 작품은 무엇입니까? –

+0

viewDidLoad의 두 버전을 게시 했습니까? – CodaFi

+0

와우. 두뇌 방귀. 내가 NSLog sharedManager.vidName 일 때 그것은 nil이 아닙니다. 올바른 문자열은 sharedManager.vidName에 보관됩니다. 이게 당신이 의미 한거야? –

1

체크 아웃 콘솔 로그를하고이 같은 말한다면 참조 :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter' 

그렇다면, 그때 sharedManager.vidName는 여기

내가 로그에 얻고 무엇을 @ "vid_name"과는 분명히 다르며 경로를 성공적으로 찾을 수 없습니다. 어쩌면 @ "vid_name.mp4"? 그럼 당신은 아마 한번 시도해

NSString *url = [[NSBundle mainBundle] pathForResource:tempName ofType:nil]; 

NSString *url = [[NSBundle mainBundle] pathForResource:tempName ofType:@"mp4"]; 

를 교체해야합니다.

'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter' 

바르 'URL이'나는 당신이 그것을 NSLog 경우 무기 호입니다 보장 할 수 sharedManager.vidName; 달리 NULL이 아니기 때문에 두 번째는 작동 의미 :

+0

콘솔 로그에 나와 있습니다. 그 줄을 nil과 같은 형식의 새로운 코드 줄로 바꾸려고했지만 여전히 작동하지 않습니다. ( –

+0

Ok. NSLog (@ " '% @'", tempName)의 출력을 보여주십시오. 파일 이름에 불필요한 공백이 있거나 어쩌면 파일 이름에 불필요한 공간이 될 수도 있습니다. – lukasz

+0

로그에 NSLog의 출력을 추가했습니다 ( –

0

내가 본 가장 모호한 것들 중 하나입니다 ... iOS에서 풍성한 것 중 하나. GetLocationVideo.m4v라는 파일에 동일한 문제가있었습니다. 다른 파일도 잘 작동했습니다. 그 중 하나가 MVI_1723.MOV였습니다. 몇 시간 후에 뭔가 일을하면 1 초 이상 걸릴 것입니다. xcode의 리소스에있는 참조 목록에서 GetLocationVideo.m4v를 삭제했습니다. GetLocationVideo.m4v 파일의 이름을 MVI_1724.MOV로 변경하고 Xcode의 resources 폴더에 다시 넣습니다. 응용 프로그램을 다시 실행하면 정상적으로 작동합니다. xcode의 비디오 파일 확장자는 대문자 여야합니다. .MOV가 작동합니다. 나는 .MP4 또는 확장 프로그램을 사용하지 않았습니다. 왜? 나는 모른다. 아무런 의미를 가지지 않는 버그 나 것들이 너무 많아서 이유를 이해하려고 시도 할 가치가없는 10,000 페이지의 문서를 읽어야합니다. 다음 큰 물건이 당신 앞에서 올 때까지 계속 가보십시오. 다른 사람들이 같은 라인을 따라 어려움을 겪는 데 도움이되기를 바랍니다.

관련 문제