2014-10-07 5 views
0

안녕하세요 친구 코어 데이터에서 가져 오기 요청을 수행하는 동안 내 응용 프로그램이 충돌합니다. 아래는 충돌하는 동안 표시되는 메시지입니다.코어 데이터에서 레코드를 가져 오는 동안 응용 프로그램이 충돌하는 경우

는 "2014년 10월 7일 14 : 38 : 07.203 사회 [1540 : 60B] - [AppDelegate에 fetchAllAds] : 38 : 07.209 사회적 인식 선택기 인스턴스 0x9725da0 2014년 10월 7일 (14)로 전송 [1540 60B] * 인해 캐치되지 않는 예외 'NSInvalidArgumentException', ** 이유로 응용 프로그램 종료 : -

(
0 CoreFoundation      0x025201e4 __exceptionPreprocess + 180 
1 libobjc.A.dylib      0x01e1e8e5 objc_exception_throw + 44 
2 CoreFoundation      0x025bd243 -[NSObject(NSObject) 
doesNotRecognizeSelector:] + 275 
3 CoreFoundation      0x0251050b ___forwarding___ + 1019 
4 CoreFoundation      0x025100ee _CF_forwarding_prep_0 + 14 
5 Social        0x00002e5b -[ShoppingCartViewController viewDidLoad] + 
139 
6 UIKit        0x00bfd33d -[UIViewController loadViewIfRequired] + 696 
7 UIKit        0x00bfd5d9 -[UIViewController view] + 35 
8 UIKit        0x00c0cf89 -[UIViewController shouldAutorotate] + 36 
9 UIKit        0x00c0d2d1 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297 
10 UIKit        0x00eab3d5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330 
11 UIKit        0x00c095d5 -[UIViewController presentViewController:withTransition:completion:] + 6538 
12 UIKit        0x00c09aef -[UIViewController presentViewController:animated:completion:] + 130 
13 UIKit        0x00c09b2f -[UIViewController presentModalViewController:animated:] + 56 
14 UIKit        0x01053e00 -[UIStoryboardModalSegue perform] + 271 
15 UIKit        0x01042f0c -[UIStoryboardSegueTemplate _perform:] + 174 
16 UIKit        0x01042f87 -[UIStoryboardSegueTemplate perform:] + 115 
17 libobjc.A.dylib      0x01e30880 -[NSObject performSelector:withObject:withObject:] + 77 
18 UIKit        0x00ae03b9 -[UIApplication sendAction:to:from:forEvent:] + 108 
19 UIKit        0x00ae0345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61 
20 UIKit        0x00be1bd1 -[UIControl sendAction:to:forEvent:] + 66 
21 UIKit        0x00be1fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577 
22 UIKit        0x00be1243 -[UIControl touchesEnded:withEvent:] + 641 
23 UIKit        0x00b1fddd -[UIWindow _sendTouchesForEvent:] + 852 
24 UIKit        0x00b209d1 -[UIWindow sendEvent:] + 1117 
25 UIKit        0x00af25f2 -[UIApplication sendEvent:] + 242 
26 UIKit        0x00adc353 _UIApplicationHandleEventQueue + 11455 
27 CoreFoundation      0x024a977f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
28 CoreFoundation      0x024a910b __CFRunLoopDoSources0 + 235 
29 CoreFoundation      0x024c61ae __CFRunLoopRun + 910 
30 CoreFoundation      0x024c59d3 CFRunLoopRunSpecific + 467 
31 CoreFoundation      0x024c57eb CFRunLoopRunInMode + 123 
32 GraphicsServices     0x03ca25ee GSEventRunModal + 192 
33 GraphicsServices     0x03ca242b GSEventRun + 104 
34 UIKit        0x00adef9b UIApplicationMain + 1225 
35 Social        0x00017a2d main + 141 
36 libdyld.dylib      0x0393b701 start + 1 
37 ???         0x00000001 0x0 + 1 

) 의 libc : *** 먼저 던져 호출 스택 '[AppDelegate에 fetchAllAds] 인식 할 수없는 선택기 인스턴스 0x9725da0로 전송' ++ abi.dylib : NSException 유형의 catch되지 않는 예외로 종료합니다. (lldb)

아래 코드는 제 코드입니다.

- (void)viewDidLoad 
{ 
    DBManager* manager = [UIApplication sharedApplication].delegate; 
    self.fetchedRecordsArray = [manager fetchAllAds]; 
    [self.shoppingtbl reloadData]; 
} 

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections. 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [self.fetchedRecordsArray count]; 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath 
    *)indexPath 
{  
    static NSString *CellIdentifier = @"ShoppingCart"; 
    ShoppingCart *cell = (ShoppingCart*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier 
    forIndexPath:indexPath]; 
    Ad * record = [self.fetchedRecordsArray objectAtIndex:indexPath.row]; 
    cell.addesc.text = [NSString stringWithFormat:@"%@",record.data]; 
    return cell; 
} 

참고 모든 핵심 데이터 기능은 dbmanager라는 별개의 파일에서 폐기했습니다.

답변

0

AppDelegate에는 fetchAllAds이 없다는 것을 알려줍니다.

빠른 메모와 마찬가지로. 그것 어쨌든 그 기능을 가지고해서는 안됩니다.

앱 대리인에 뭔가가 누락되었습니다. 이 문제를 해결할 수 없다면 앱 델리게이트에 코드를 표시해야합니다.

편집

오! 방금 깨달았 어. 당신은라는 클래스 DBManager하지만 당신이 그것을로드하는 방법 ...

DBManager* manager = [UIApplication sharedApplication].delegate; 

실제로 재산에 UIAppDelegate를 가하고있다.

당신은

DBManager *manager = [[DBManager alloc] init]; 

오류를 중지합니다 ... 뭔가를해야합니다. 이 일을 무엇

...

당신이 [manager fetchAllAds];을 실행

그것이 재산 manager을 받고있다.

이것은 App Delegate를로드하는 방법 때문에 참조됩니다. 어쩌면 당신의 DBManager 앱 위임의 속성처럼

EDIT 1

OK, 그것은 소리.

다음과 같이로드 할 수 있습니다.

DBManager *manager = [[UIApplication sharedApplication] delegate].dbManager; //or whatever the property is. 
+0

새 개체를 만드는 경우

그래서 [AppDelegate에 가져 오기 광고] ...하지만 내가 무엇을 할 수 있는지 보여줍니다. – user3354840

+0

@ user3354840 네,하지만 DBManager * manager'를 가지고 있고 그 중에'app delegate '를 넣고 있습니다. 그러면'fetchAllAds'를 실행하려고하면 존재하지 않습니다. 당신은'DBManager'를 만들고 그것을'manager' 속성에 넣어야합니다. – Fogmeister

+0

지금은 응용 프로그램이 작동 중입니다 ...하지만 모든 필드는 null .. 무엇을 할 수 있습니다 ..하지만 데이터는 DB에 저장됩니다. – user3354840

0

친구이 coreData의 문제는 아니지만 당신은 당신의 코드 [UIApplication sharedApplication].delegate;appDelegate하지 DBManager의 객체를 반환합니다 viewDidLoad에

다음
- (void)viewDidLoad 
{ 
DBManager* manager = [UIApplication sharedApplication].delegate; 
self.fetchedRecordsArray = [manager fetchAllAds]; 
[self.shoppingtbl reloadData]; 
} 

에서 잘못된 개체에 액세스하는 당신이 그것을 저장하는 당신의 잘못된 DBManager입니다. appDelegate에 dbManager 속성이 있으면이 방법으로 [[[UIApplication sharedApplication] delegate] dbManager]에 액세스하십시오. 당신이 그런 방법

- (void)viewDidLoad 
    { 
    DBManager* manager = [[[UIApplication sharedApplication] delegate] dbManager]; 
    self.fetchedRecordsArray = [manager fetchAllAds]; 
    [self.shoppingtbl reloadData]; 
    } 

에 앱 액세스 그것에 DBManager의 속성이 있거나 내가 지정하고 있지 않다 내 코드에서 여기

- (void)viewDidLoad 
    { 
    DBManager* manager = [[DBManager alloc] init]; 
    self.fetchedRecordsArray = [manager fetchAllAds]; 
    [self.shoppingtbl reloadData]; 
    } 
+0

지금 당장은 그 덕분에 일하고 있습니다. 그러나 모든 필드는 null .. 무엇을 할 수 있습니까 .. – user3354840

+0

@ user3354840 그래서 새 개체를 만들었거나 appDelegate에서 속성에 액세스 했습니까? – iHulk

+0

이 새 객체를 만들었습니다 .... – user3354840