2014-07-25 1 views
0

Вот строка кодаNSURL непризнанным селектор послал к экземпляру

cell.imageURL=[NSURL URLWithString:self.imageURLs[indexPath.row]]; 

Здесь след ошибка

[UITableViewCell setImageURL:]: unrecognized selector sent to instance 0x906da70 
2014-07-24 17:16:50.049 MyApp_iOS[9443:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell setImageURL:]: unrecognized selector sent to instance 0x906da70' 
*** First throw call stack: 
(
    0 CoreFoundation      0x01a8c1e4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x016ad8e5 objc_exception_throw + 44 
    2 CoreFoundation      0x01b29243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275 
    3 CoreFoundation      0x01a7c50b ___forwarding___ + 1019 
    4 CoreFoundation      0x01a7c0ee _CF_forwarding_prep_0 + 14 
    5 MyApp_iOS       0x0007f518 -[BCDDogViewController tableView:cellForRowAtIndexPath:] + 504 
    6 UIKit        0x0046611f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412 
    7 UIKit        0x004661f3 -[UITableView _createPreparedCellForGlobalRow:] + 69 
    8 UIKit        0x00447ece -[UITableView _updateVisibleCellsNow:] + 2428 
    9 UIKit        0x0045c6a5 -[UITableView layoutSubviews] + 213 
    10 UIKit        0x003dc964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355 
    11 libobjc.A.dylib      0x016bf82b -[NSObject performSelector:withObject:] + 70 
    12 QuartzCore       0x03ef745a -[CALayer layoutSublayers] + 148 
    13 QuartzCore       0x03eeb244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 
    14 QuartzCore       0x03eeb0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26 
    15 QuartzCore       0x03e517fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294 
    16 QuartzCore       0x03e52b85 _ZN2CA11Transaction6commitEv + 393 
    17 QuartzCore       0x03e53258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 
    18 CoreFoundation      0x01a5436e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 
    19 CoreFoundation      0x01a542bf __CFRunLoopDoObservers + 399 
    20 CoreFoundation      0x01a32254 __CFRunLoopRun + 1076 
    21 CoreFoundation      0x01a319d3 CFRunLoopRunSpecific + 467 
    22 CoreFoundation      0x01a317eb CFRunLoopRunInMode + 123 
    23 GraphicsServices     0x03a805ee GSEventRunModal + 192 
    24 GraphicsServices     0x03a8042b GSEventRun + 104 
    25 UIKit        0x0036df9b UIApplicationMain + 1225 
    26 MyApp_iOS       0x000577c2 main + 130 
    27 libdyld.dylib      0x0216d701 start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

И свойство в вопросе

@property(strong,nonatomic) NSURL *imageURL; 

с сеттер

-(void)setImageURL:(NSURL *)imageURL 
{ 
    _imageURL=imageURL; 
    [self startDownloadingImage]; 
} 

Странная вещь, с которой это работает, и около часа назад она перестает работать и начинает бросать это исключение.

обновление

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    BCDDogImageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[BCDDogImageTableViewCell cellPrototypeIdentifier] forIndexPath:indexPath]; 
    NSLog(@"THE CELL IS: %@ ", cell); 
    cell.imageURL=[NSURL URLWithString:self.imageURLs[indexPath.row]]; 
    return cell; 
} 
+2

'cell' является' UITableViewCell', а не экземпляром вашего пользовательского класса ячеек. – rmaddy

+0

Можете ли вы добавить свой 'cellForRowAtIndexPath:' здесь. Это выглядит хорошо для меня. – Ryan

+0

@rmaddy, вы можете быть прав, потому что мой журнал говорит, что ячейка действительно '> ', но я не вижу, как это возможно. –

ответ

2

Ошибка в том, что ваша клетка на самом деле UITableViewCell экземпляр и не является экземпляром пользовательского класса клеток.

Обязательно зарегистрируйте свой собственный класс ячеек для ячейки.