2013-12-08 4 views
0

내 응용 프로그램이 오류를 얻고있다오류 새로 고침 트위터 트윗

- (void)fetchInstagramPics { 
    instaPics = [[NSMutableArray alloc] init]; 
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults]; 
    BOOL *status = [user boolForKey:@"isInstagramLoggedIn"]; 
    if (status) { 
     [[InstagramClient sharedClient] getPath:@"users/self/feed" 
            parameters:nil 
             success:^(AFHTTPRequestOperation *operation, id responseObject) { 
              // NSLog(@"Response: %@", responseObject); 
              self.timelineResponse = [responseObject mutableCopy]; 
              [self.instaPics addObjectsFromArray:responseObject[@"data"]]; 
              [self updateArrays]; 
              [self.tableView reloadData]; 
             } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
              NSLog(@"Failure: %@", error); 
             }]; 
    } 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     [self.tableView reloadData]; }); 


} 


- (void)updateArrays { 
    instaPics = self.timelineResponse[@"data"]; 
    totalFeed = [tweets arrayByAddingObjectsFromArray:instaPics]; 

} 

- (void)fetchTimeline { 
    [self fetchInstagramPics]; 
    [self fetchTweetsAuth]; 
    [self updateArrays]; 
    [self.tableView reloadData]; 
} 

- (void)refetchTimeline { 
    [self fetchInstagramPics]; 
    [self fetchTweets]; 
    [self updateArrays]; 
    [self.tableView reloadData]; 

} 

- (void)fetchTweetsAuth { 
    self.twitterClient = [[AFOAuth1Client alloc] initWithBaseURL:[NSURL URLWithString:@"https://api.twitter.com/1.1/"] key:@"4oFCF0AjP4PQDUaCh5RQ" secret:@"NxAihESVsdUXSUxtHrml2VBHA0xKofYKmmGS01KaSs"]; 

    [self.twitterClient authorizeUsingOAuthWithRequestTokenPath:@"/oauth/request_token" userAuthorizationPath:@"/oauth/authorize" callbackURL:[NSURL URLWithString:@"floadt://success"] accessTokenPath:@"/oauth/access_token" accessMethod:@"POST" scope:nil success:^(AFOAuth1Token *accessToken, id responseObject) { 
     [self.twitterClient registerHTTPOperationClass:[AFJSONRequestOperation class]]; 
     [self.twitterClient getPath:@"statuses/home_timeline.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { 
      NSArray *responseArray = (NSArray *)responseObject; 
      [responseArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 
       NSLog(@"Success: %@", obj); 
       tweets = responseArray; 
      }]; 
     } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
      NSLog(@"Error: %@", error); 
     }]; 

    } failure:^(NSError *error) { 
     NSLog(@"Error: %@", error); 
    }]; 
} 

- (void)fetchTweets{ 
     [self.twitterClient registerHTTPOperationClass:[AFJSONRequestOperation class]]; 
     [self.twitterClient getPath:@"statuses/home_timeline.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { 
      NSArray *responseArray = (NSArray *)responseObject; 
      [responseArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 
       NSLog(@"Success: %@", obj); 
       tweets = [tweets copy]; 
       tweets = responseArray; 
      }]; 
     } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
      NSLog(@"Error: %@", error); 
     }]; 
} 

- (void)refresh:(UIRefreshControl *)refreshControl { 
    [self refetchTimeline]; 
    [refreshControl endRefreshing]; 
} 

tweets 배열라는 배열 아래에있는 instaPics 배열과 공유 totalArray 그래서 내가 fetchInstagramPics 함수를 포함 시켰습니다. 나는 그것이 복잡하게 들리지만, 귀하의 도움은 깊이 감사하게 생각합니다. 여기

는 스택 트레이스입니다 :에서

STACK TRACE : 
(
    0 CoreFoundation      0x02b6b5e4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x027978b6 objc_exception_throw + 44 
    2 CoreFoundation      0x02b6b3bb +[NSException raise:format:] + 139 
    3 CoreFoundation      0x02bf2365 -[__NSCFArray insertObject:atIndex:] + 101 
    4 CoreFoundation      0x02b2f2d0 -[NSMutableArray insertObjects:count:atIndex:] + 208 
    5 CoreFoundation      0x02b2ef69 -[NSMutableArray insertObjectsFromArray:range:atIndex:] + 425 
    6 CoreFoundation      0x02b2ed15 -[NSMutableArray addObjectsFromArray:] + 661 
    7 MyApp        0x0003c6c6 __42-[StreamViewController fetchInstagramPics]_block_invoke + 278 
    8 MyApp        0x0001e73b __64-[AFJSONRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke91 + 43 
    9 libdispatch.dylib     0x035187f8 _dispatch_call_block_and_release + 15 
    10 libdispatch.dylib     0x0352d4b0 _dispatch_client_callout + 14 
    11 libdispatch.dylib     0x0351b75e _dispatch_main_queue_callback_4CF + 340 
    12 CoreFoundation      0x02bd0a5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14 
    13 CoreFoundation      0x02b116bb __CFRunLoopRun + 1963 
    14 CoreFoundation      0x02b10ac3 CFRunLoopRunSpecific + 467 
    15 CoreFoundation      0x02b108db CFRunLoopRunInMode + 123 
    16 GraphicsServices     0x045309e2 GSEventRunModal + 192 
    17 GraphicsServices     0x04530809 GSEventRun + 104 
    18 UIKit        0x0192ad3b UIApplicationMain + 1225 
    19 MyApp        0x00062b1d main + 141 
    20 libdyld.dylib      0x037bf70d start + 1 
) 
+0

나는 대답을 –

답변

0

당신의 -[AppDelegate didFinishLaunchingWithOptions:] : 모든 방법을 아래 파일의 맨 아래에있는 AppDelegate에에서

#ifdef DEBUG 
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); 
#endif 

:

#ifdef DEBUG 
void uncaughtExceptionHandler(NSException *ex) 
{ 
    NSLog(@"CRASH :\n %@", ex.reason); 
    NSLog(@"STACK TRACE :\n %@", ex.callStackSymbols); 
    exit(0); 
} 
#endif 

이렇게하면 콘솔에 스택 추적이 표시됩니다. 이후에 어떤 함수가 크래시를 일으키고 고치거나 stacktrace를 게시하여 질문을 편집하여 보겠습니다.
EDIT 스택 추적을보고 난 후 [self.instaPics addObjectsFromArray:responseObject[@"data"]];을 입력하면 instaPics = [[NSMutableArray alloc] init];이됩니다. self.instaPics은 변경 불가능한 NSArray입니다. 나도 모르겠다, 당신의 논리가 작동해야하는 방법, 당신은 어느 쪽이든 self.instaPics = [[NSMutableArray alloc] init]; 또는 [instaPics addObjectsFromArray:responseObject[@"data"]];

+0

업데이트했습니다. 기본 질문과 함께 스택 추적을 추가했습니다. – Prad