unrecognized selector sent to instance 0x7ff971e1f920 - ios

When I run my iOS app on the iPhone 6 simulator on Xcode 6.1 it stops on this line:
[cell configure:[feeds objectAtIndex:indexPath.row]];
Error:
'-[UITableViewCell configure:]: unrecognized selector sent to instance 0x7ff971e1f920'

Presumably you've defined a custom cell subclass with a configure: method.
Your subclass isn't being used - that message means you're calling the method on a plain UITableViewCell.
The most common cause of this is forgetting to set the cell class in the storyboard. Otherwise, you'll need to show how you're creating cell.

You have called the configure method on a UITableViewCell instance, but this class doesn't have that method. I suspect that you meant to instantiate your own UITableViewCell subclass that does have that method.

Related

'+[UIImage didReceiveMemoryWarning:]: unrecognized selector sent to class 0x1b6eba078

Iam using uimageview in tableview, before adding uiimage view in tableview the Application get crash due to this problem ( +[UIImage didReceiveMemoryWarning:]: unrecognized selector sent to class 0x1a0bd1798 ).
didReceiveMemoryWarning is UIViewController method, so, suppose, you pass UIImage instance to place, where UIViewController expected

how to set up a selector from a different UIView object for UITapGestureRecognizer

This should be straight forward but I am having some issues with this.
I have an UIView A which has a function A. I create a Selector for function A in UIView A.
SEL littleSelector = #selector(handleTapButton1);
I create UIView B and pass this selector to UIView B constructor and save it in UIView B. I set up UITapGestureRecognizer in UIView B and I assign selector from UIViewA "littleSelector" as its action. I get an exception = unrecognized selector sent to instance. I know selectors are not really function pointers but look up numbers. I also made sure that UIView A is retained.
Any ideas ?
A selector needs to be paired with an appropriate target. If you supply a selector for A and a target instance of B you will have this kind of issue. You need to set the target properly to A so the method represented by the selector is called on the right class instance.

[Not A Type release]: message sent to deallocated instance in UITableView

I get a crash when quickly scrolling through a UITableView.
The crash is :
*** -[Not A Type release]: message sent to deallocated instance 0x1aded1c0
And the exception breakpoint indicates this as the source:
- (void)updateInfo:(Item*)item{
if (!item) {
return;
}
Program *prg = (Program *)item;
self.titleLabel.text = prg.title; // crash here
self.descriptionLabel.text = prg.item_description;
}
This method is inside the custom table view cell subclass and it is called when data from the internet is ready to be displayed in the cell.
I have never seen this kind of crash before...
What is the best way to fix it?
Reason:
As you scroll the tableview, the cells on top get released and when data comes from internet for those cell, they have already been released. So, change your logic. You generally receive this error when you try to access and update an object which has already been released. As you are saying that this method is inside your custom cell, so it clearly indicates that the cell is already released. That's why your app gets crashed when you try to update any view of that cell.
Solution:
Either you can reload your whole tableview or reload those specific cells when you receive data.
Where are you calling the method "updateInfo"? You should call this in cellForRowAtIndexPath. You should not store a reference to a cell and then call this.
When you get the data from your service you just call self.tableView reloadData (or perhaps reloadRowsAtIndexPaths if you know which row needs update and dont want a performance hit)

BAD_ACCESS & NSInvalidArgumentException in working with UIPickerView

I'm beginner in working with UIKit. When I tired to work with UIPickerView in iOS 7 SDK I faced to a hard-to-solve problem.
We know that UIPickerView needs two resources to work perfectly: dataSource & delegate. So I wrote a class named "KMPickerProtocols". I adopted it to UIPickerViewDataSource & UIPickerViewDelegate Protocols and then I added some extra setter methods to it.
KMPickerProtocols is adopted to all of essential methods of dataSource and delegate Protocols + the necessary optional method for setting title of each row (pickerView:titleForRow:forComponent). all these methods get things done without any problem (in normal situations).
Finally I set the delegate and dataSource properties of my UIPickerView (named _accountPicker) manually with this piece of code:
NSArray *delegateAgent = [[KMTwitterDelegate new] run ];
_accountPicker.dataSource = [delegateAgent objectAtIndex:0];
_accountPicker.delegate = [delegateAgent objectAtIndex:1] ;
(the run method is designed to set some properties including height of each row and ...)
Now, when I run my app it will show my twitterAccounts stored in system(accounts framework) in the form of UIPickerView. but there is a problem: As soon as I scroll the picker view or tap on any row, the program will crash and I get BAD_ACCESS (code=2 , address = 0x1) in this line of code:
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([KMAppDelegate class]));
}
and also there are sometimes that I get signal SIGABRT in above line. in these situations Log Says:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSMallocBlock pickerView:titleForRow:forComponent:]: unrecognized selector sent to instance 0x8c75ad0'
I will appreciate if you help me to deal with this problem. I really don't know where the bug is. but I guess this screen shots will be helpful to find that:
The problem in above screenshot is that UIPicker called the "pickerView:titleForRow:forComponent" method for row 0, three times instead of one time. I just don't know whether that is this because myFault or because the typical behaviour of UIPicker.
You are sending the message pickerView:titleForRow:forComponent: to an object of type NSMallocBlock. This is a message automatically sent from the picker to its datasource, so my assumption is that you are assigning the datasource:
_accountPicker.dataSource = [delegateAgent objectAtIndex:0];
The datasource you assign does not conform the protocol UIPickerViewDataSource
Checkout what returns [delegateAgent objectAtIndex:0]; and make sure it is what you expect it to be.

Popovers in UITableView

I would like to display popovers with UITableView's as content (this works) on some button presses and then get the selected item as string as buttontitle or some textview text. I've found a few example on how to do this with protocols but still get an error.
My code:
In popoverViewController.h
#protocol popoverViewControllerDelegate <NSObject>
-(void)getRowText:(NSString *)string;
#end
I declare an id delegate2 variable and set its property to:
#property(nonatomic,assign) id<popoverViewControllerDelegate> delegate2;
In the popoverViewController.m file I synthesize the variable, and in didSelectRowAtIndexPath method I have this, and this line seems to cause the error I`m having:
[self.delegate2 getRowText:[someArray objectAtIndex:indexPath.row];
In mainViewController.m I add the popoverViewControllerDelegate to the ViewControllers protocol and have its header file imported. And then have some code in the -(void)getRowText: method which doesnt get called.
UIPopovers and such are set up as they work as needed, problem arises when I press a row in the tableview. I get the
Terminating app due to uncaught
exception
'NSInvalidArgumentException', reason:
'* -[UIPopoverViewController
getRowText:]: unrecognized selector
sent to instance 0x57ca80'
Could anyone give some advice with this?
Finally found the error and cant believe how silly I/it was.
I had a viewController.delegate2 = self. line with period instead of a semicolon, I wonder why it compiled tho.

Resources