Reputation: 493
My app is crashing at a point showing message "message send to deallocated instance",when i enabled Zombies in my app.I am simply setting a NSString to another class which is being presented from a view controller.On further investigating I came to know that instead of passing a nsstring i got nscfstring .How to solve the issue?
Upvotes: 4
Views: 95
Reputation: 493
I finally resolved this issue by changing NSString class to int .Actually I was getting product id in NSCFsting format that i needed it another view controller which was being presented .I just typecasted the productid to int by using the code "[ productid intvalue ]" and created an object with "int type" in the view controller which was being presented,thereafter by using setter and getter method I was able to fetch that value. –
Upvotes: 1
Reputation: 95
"Message send to deallocated instance" is an error that usually occurs when your class gets dealloc'ed but is still a delegate of something (could be a table view, collection view etc.), hence still trying to receive messages. If so, you could try setting these delegates to nil in dealloc method of your view controller:
- (void)dealloc {
tableview.delegate = nil;
}
Hope this helps
Upvotes: 1
Reputation: 31637
What I used to do is below in earlier days.
Define UILabel and make it hidden...
In viewDidLoad, assing NSString value to this UILabel
Now, instead of NSString check data of this UILabel...
This way, I used to solve the issue of NSString.
Upvotes: 0
Reputation: 2049
As a subclass of the NSString class, the _NSCFString is always guaranteed to respond to set string or isEqualToString. You should log all the data and see if there's anything else that's causing the crash. See more here:
Upvotes: 0