A_Curious_developer
A_Curious_developer

Reputation: 493

My app crashes showing message send to deallocated instance

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

Answers (4)

A_Curious_developer
A_Curious_developer

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

prak253
prak253

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

Fahim Parkar
Fahim Parkar

Reputation: 31637

What I used to do is below in earlier days.

  1. Define UILabel and make it hidden...

  2. In viewDidLoad, assing NSString value to this UILabel

  3. Now, instead of NSString check data of this UILabel...

This way, I used to solve the issue of NSString.

Upvotes: 0

Atif Imran
Atif Imran

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

Related Questions