unrecognized selector sent to instance - mistake in properties? - iphone

I know that this question is asked for many times but i am working on it hard and can not find the mistake!
I have made a navigation based application.
To costumize the appereance of the table view cells i used this method in my RootViewController:
- (UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Verwaltung Information * selectedFormel = [listOfFormularies objectAtIndex:indexPath.row];
cell.textLabl.text = selectedFormel.nameFormel;
return cell;
}
The variable "nameFormel" is declared in VerwaltungInformation as NSString with property and synthesize.
But instead I get this error message:
[FormelViewController nameFormel]: unrecognized selector sent to instance
Terminating app due to uncaught exception 'NSInvalidArgument', reason : [FormelViewControlle nameFormel]: unrecognized selector sent to instance
I need some help! Since days I have been working on it but I can NOT find the error...If somebody need some more details to answer, please leave a comment.

Your problem is that [listOfFormularies objectAtIndex:indexPath.row] returns an FormelViewController object, not an object of type VerwaltungInformation.
You should check your data (i.e. the listOfFormularies array).

Related

Implementing countbyenumeratingwithstate for custom UICollectionviewCell

I am building an app with a CollectionView filled with custom CollectionViewCell.
I added a button "select all/deselect all" which is obviously supposed to affect all the cell in my collectionView. To do this I intended to use a for-loop like this:
for(customCollectionViewCell* cell in self.collectionView){
// some code
}
However i first get a warning saying:
Collection expression type "UICollectionView *" many not correspond to "countByEnumeratingWithStage:objects:count"
And when I compile the program and click on the button, the app crash with the following error message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionView countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x7973e00'
Does anyone have an idea on how to solve this?
Many thanks for your help!
Don't iterate the collection view itself, but rather the array of cells it returns by calling the visibleCells method on it.

Error while running iPhone App Help - __NSCFConstantString error meaning

Could someone please tell me what this means:
2013-02-08 11:19:49.394 xxxxx[10545:907] set selected tab with tag 3
2013-02-08 11:19:49.560 xxxxx[10545:907] did select item
2013-02-08 11:19:49.562 xxxxx[10545:907] tab clicked
2013-02-08 11:19:49.566 xxxxx[10545:907] will show view controller MoreViewController
2013-02-08 11:19:49.567 xxxxx[10545:907] will show other VC
2013-02-08 11:19:49.579 xxxxx[10545:907] -[__NSCFConstantString offImage]: unrecognized selector sent to instance 0x21994c
2013-02-08 11:19:49.580 xxxxx[10545:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString offImage]: unrecognized selector sent to instance 0x21994c'
I just tried modifying some code, however the modifications did not work. So pressed z and undid everything I modified, but now I get this error.
The "unrecognized selector sent to instance" error always means one thing: you are calling a method on an instance that does not support it. In this particular case, you have a line in your code that looks like this:
[someObject offImage];
On this line, someObject is an instance of string, which does not have an offImage method.
This problem could be caused by passing an object of a wrong type to some other method:
[someTarget objectWithOffImage:#"Hello"];
The method could be expecting an object that responds to offImage, but you are passing it a string.
Finally, you may be trying to invoke a method in a category, but you forgot to import the header file for the category.
You are sending the message -offImage to an instance of NSString which does not have a method with that name. Alter your code so that -offImage is sent to the right kind of object

Passing UISearchBar.text to another function

It's my first time working with a UISearchBar and so far it went fine, but now after clicking "search" I'm trying to pass the text to another function that handles the search.
[_searchModel searchIssueForTerm:searchBar.text inIssue:_dataModel.currentIssue];
This just throws me an error, saying:
-[CFString copyWithZone:]: message sent to deallocated instance 0x7dee900
But when I use this, it just works
[_searchModel searchIssueForTerm:#"test" inIssue:_dataModel.currentIssue];
Why is this hapenning? In my - (void)searchIssueForTerm:(NSString *)searchTerm inIssue:(Issue *)issue I store the NSString in another variable, why would it get deallocated then?
After searching for a while I managed to fix it by just saving the variable somewhere else, seems it was getting lost along the way.
_currentSearchTerm = [[NSString alloc] initWithString:searchTerm];

Error: "-[NSCFString sizeWithTextStyle:]: unrecognized selector" in IPhone SDK

I get the following error while running my app.
'-[NSCFString sizeWithTextStyle:]: unrecognized selector
I have not used sizeWithTextStyle in my entire project.
So what could be wrong?
I get error on return pos; statement below
Code:
(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *pos = [[UIView alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,35.0)];
return pos;
}
Error in Console:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString sizeWithTextStyle:]: unrecognized selector sent to instance 0x7044b50'
Because of indentation problem while putting whole crash log here, I am putting the screenshot of the crash log
I think, the problem is somewhere else, not in this line of code. The object is not able to retain itself. Post the code, where you are using the sizeWithTextStyle method
Have you the -all_load flag on your link settings?
This issue comes up a lot. You need to add -all_load and -ObjC to your applications link flags.
*EDIT : *
Crash appears to occur on line:
CGSize textSize = [self.text sizeWithTextStyle:textStyle];
in class: CPTextLayer method: sizeToFit
which is called from within class CPTextLayer method initWithText:
-(id)initWithText:(NSString *)newText style:(CPTextStyle *)newStyle
....
[self sizeToFit];
**try to set with iOS 4 and not with 3.1.3 **
When you have memory management issues (selectors being sent to the wrong instances is one symptom of memory management issues), there are a number of things you can do:
Re-read the Cocoa memory management rules and make sure that you're following them.
Run the static analyser. This will often pick up places where you have neglected the memory management rules.
Try using NSZombieEnabled to find out whether [and when] you are sending messages to unallocated instances.
I am also getting same error but now it's solved.
Need to do simple thing, set the value of Other linker flag.
below I have mention the steps.
Project name - Build Setting - Other linker flag (use search bar to search) - "-ObjC"
You should change your code to use pointers like this:
UIView *pos = [[UIView alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,35.0)];
return pos;
Pay attention to asterisk!
And of course the ; in the end of allocation statement!

trying to obtain an objects title variable gives unrecognized selector sent to instance

I have an object which holds a title and an indexReference. I save the object to an array and that works correctly.
I then try to load from the array and populate the tableview.
I use this code.
//fill it with contents
SavedFav *temp = [tableViewData objectAtIndex:indexPath.row];
cell.textLabel.text = temp.title;
I then get an error as the following
2010-07-01 15:42:46.386 Daily Quote[1308:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString title]: unrecognized selector sent to instance 0x23f6688'
What is causing this problem?
Thanks in advance.
"temp" is a string obviously, so it's too many answers to give, either you filled tableViewData with strings and trying to obtain title from a string (which is unrecognized) or you have problem with memory there, without seeing more code it's hard to say.
however try
cell.textLabel.text = temp;
and check what's inside, that will give you a good lead.