I am trying to update a UILabel within a Cell when a button within the cell is tapped. How would I go on as to approaching this. Here is my code for the creation of the UITableViewCell:
EDITED: On TAP Method
- (void)likeButtonTap:(InstagramLikeButton *)sender {
[sender setSelected:!sender.selected];
// Set objectID
NSString *objectID = sender.objectID;
int *likesCount = sender.likesCount;
likesCount = likesCount + 1;
NSString *likesString = [NSString stringWithFormat:@"%d",likesCount];
// Get Cell
NSIndexPath *i=[self indexPathForCellContainingView:sender.superview];
InstagramCell *cell = (InstagramCell*)[self.tableView cellForRowAtIndexPath:i];
cell.likeLabel = likesString;
NSString *path = [NSString stringWithFormat:@"media/%@/likes", objectID];
[[InstagramClient sharedClient] postPath:path parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Successfully Liked Picture");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Failure: %@", error);
}];
[sender increaseLikeCount:sender];
NSLog(@"Successfully Liked Picture");
}
Here is the error I am receiving:
Floadt[2669:176980] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setText:]: unrecognized selector sent to instance 0x7f7f7a8bda50'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107541c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000106c7ebb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001075490ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010749f13c ___forwarding___ + 988
4 CoreFoundation 0x000000010749ecd8 _CF_forwarding_prep_0 + 120
5 Floadt 0x00000001036d455f -[InstagramTableViewController tableView:cellForRowAtIndexPath:] + 3663
6 UIKit 0x0000000105ab3a28 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
7 UIKit 0x0000000105a92248 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2853
8 UIKit 0x0000000105aa88a9 -[UITableView layoutSubviews] + 210
9 UIKit 0x0000000105a32a2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
10 QuartzCore 0x00000001057f6ec2 -[CALayer layoutSublayers] + 146
11 QuartzCore 0x00000001057eb6d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
12 QuartzCore 0x00000001057eb546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
13 QuartzCore 0x0000000105757886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
14 QuartzCore 0x0000000105758a3a _ZN2CA11Transaction6commitEv + 462
15 QuartzCore 0x000000010581a075 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 489
16 CoreFoundation 0x00000001074a9174 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
17 CoreFoundation 0x00000001074a8d35 __CFRunLoopDoTimer + 1045
18 CoreFoundation 0x000000010746ad3d __CFRunLoopRun + 1901
19 CoreFoundation 0x000000010746a366 CFRunLoopRunSpecific + 470
20 GraphicsServices 0x0000000109029a3e GSEventRunModal + 161
21 UIKit 0x00000001059b2900 UIApplicationMain + 1282
22 Floadt 0x000000010370ba6f main + 111
23 libdyld.dylib 0x000000010977e145 start + 1
24 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException