2014-11-14 3 views
0

iOS 앱에 테이블 뷰가있는 뷰가 있습니다. 테이블 셀은 원격 서버의 PHP 파일에서로드됩니다. 또한 데이터를 다시로드해야하는 NSTimer를 뷰 컨트롤러에 배치했습니다.테이블을 다시로드 한 후 행 수가 변경되면 앱이 다운 됨

셀에는 시간 간격에 따라 바뀔 수있는 정보가 들어 있습니다. 시간 간격에 따라 셀 수가 변경되지 않는 경우에만 정상적으로 작동합니다. 시간 간격으로 셀을 추가하면 응용 프로그램이 충돌합니다.

은 NSTimer 코드입니다 :

self.timer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(refrescar) userInfo:nil repeats:YES]; 

그리고이 방법 refrescar 코드입니다 : 나는이 하나를 시도

- (void)refrescar { 

    total_actual =0; 
    total =0; 
    [self viewDidLoad]; 


} 

:

- (void)refrescar { 

     total_actual =0; 
     total =0; 
     [self.tableView reloadData]; 


    } 

하지만 다른 코드와 마찬가지로 앱이 깨집니다. [self viewDidLoad];

도움이됩니다.

오류 로그 : 당신의 UITableView 관련이없는

2014-11-13 23:52:23.299 RestAppXXI[1552:607] -[NSNull length]: unrecognized selector sent to instance 0xcb6068 
2014-11-13 23:52:23.429 RestAppXXI[1552:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0xcb6068' 
*** First throw call stack: 
(
    0 CoreFoundation      0x00b6a1e4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x031588e5 objc_exception_throw + 44 
    2 CoreFoundation      0x00c07243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275 
    3 CoreFoundation      0x00b5a50b ___forwarding___ + 1019 
    4 CoreFoundation      0x00b5a0ee _CF_forwarding_prep_0 + 14 
    5 UIKit        0x01fd2cc7 -[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 57 
    6 UIKit        0x01fd2b13 -[UILabel textRectForBounds:limitedToNumberOfLines:] + 85 
    7 UIKit        0x01fd662e -[UILabel _intrinsicSizeWithinSize:] + 173 
    8 UIKit        0x01fd6751 -[UILabel intrinsicContentSize] + 91 
    9 UIKit        0x024b07ef -[UIView(UIConstraintBasedLayout) _generateContentSizeConstraints] + 36 
    10 UIKit        0x024b0480 -[UIView(UIConstraintBasedLayout) _updateContentSizeConstraints] + 511 
    11 UIKit        0x024b67bf -[UIView(AdditionalLayoutSupport) updateConstraints] + 110 
    12 UIKit        0x01fd6579 -[UILabel updateConstraints] + 189 
    13 UIKit        0x024b6058 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 239 
    14 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    15 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    16 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    17 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    18 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    19 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    20 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    21 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    22 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    23 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    24 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    25 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    26 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    27 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    28 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    29 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    30 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    31 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    32 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    33 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    34 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    35 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    36 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    37 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    38 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    39 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    40 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    41 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    42 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    43 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    44 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    45 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    46 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    47 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    48 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    49 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    50 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    51 UIKit        0x024b6157 __UIViewRecursionHelper + 40 
    52 CoreFoundation      0x00b0bc69 CFArrayApplyFunction + 57 
    53 UIKit        0x024b5ffc -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 147 
    54 UIKit        0x024b61d6 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 122 
    55 UIKit        0x024aa878 __62-[UIWindow(UIConstraintBasedLayout) updateConstraintsIfNeeded]_block_invoke + 43 
    56 Foundation       0x02f0b68c -[NSISEngine withBehaviors:performModifications:] + 107 
    57 Foundation       0x02d9b3c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48 
    58 UIKit        0x024aa590 -[UIWindow(UIConstraintBasedLayout) updateConstraintsIfNeeded] + 225 
    59 UIKit        0x024aa467 -[UIWindow(UIConstraintBasedLayout) layoutSublayersOfLayer:] + 90 
    60 libobjc.A.dylib      0x0316a82b -[NSObject performSelector:withObject:] + 70 
    61 QuartzCore       0x0171a45a -[CALayer layoutSublayers] + 148 
    62 QuartzCore       0x0170e244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 
    63 QuartzCore       0x0170e0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26 
    64 QuartzCore       0x016747fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294 
    65 QuartzCore       0x01675b85 _ZN2CA11Transaction6commitEv + 393 
    66 QuartzCore       0x01676258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 
    67 CoreFoundation      0x00b3236e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 
    68 CoreFoundation      0x00b322bf __CFRunLoopDoObservers + 399 
    69 CoreFoundation      0x00b10254 __CFRunLoopRun + 1076 
    70 CoreFoundation      0x00b0f9d3 CFRunLoopRunSpecific + 467 
    71 CoreFoundation      0x00b0f7eb CFRunLoopRunInMode + 123 
    72 GraphicsServices     0x041945ee GSEventRunModal + 192 
    73 GraphicsServices     0x0419442b GSEventRun + 104 
    74 UIKit        0x01e18f9b UIApplicationMain + 1225 
    75 RestAppXXI       0x000305ed main + 141 
    76 libdyld.dylib      0x049eb6d9 start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 
+0

당신이 충돌 후 오류 로그를 알 수 있습니다 서버에서 응답을받은 후 테이블을 다시로드 할 수 있습니다 NSNull 객체에 길이 방법을 요구하고있다 ? – iHulk

+0

@iHulk, 물론, 잠시 기다려주십시오. 오류 로그를 포함하여 제 질문을 업데이트 할 것입니다. – rz1965

+0

@iHulk, 질문에 오류 로그를 포함 시켰습니다. – rz1965

답변

0

. 그것은 아마도 당신이 접근하려고 시도하고있는 문자열로부터 왔을 것이지만, 그것은 nil입니다. 디버깅

-1

사용자 예외 브레이크 포인트, 당신은 NSTimer를 사용하는 이유

, 당신이

+1

이것은 설명이 아니라 대답입니다. – trojanfoe

+0

NSTimer를 사용 중입니다. 표시된 데이터가 간격 기간 동안 변경 될 수 있습니다. – rz1965

관련 문제