Rahul Vyas
Rahul Vyas

Reputation: 28720

is it necessary to release a NSInteger in iphone?

i am getting this error does some one knows about it??? 2009-07-08 18:42:36.778 FlashCards[1297:20b] Category Id=1 FlashCards(1297,0xa0690fa0) malloc: * error for object 0x4fd78a0: pointer being freed was not allocated FlashCards(1297,0xa0690fa0) malloc: * error for object 0x4fdc200: double free *** set a breakpoint in malloc_error_break to debug

Upvotes: 5

Views: 4596

Answers (3)

Barry Wark
Barry Wark

Reputation: 107754

The error message gives you a good hint in how to debug this problem: set a break point at malloc_error_break. In Xcode, open the breakpoints window (option-cmd-B). In the field that says "Double-Click for Symbol", enter malloc_error_break. Re-run your app in the debugger (select Debug from the Run menu). The debugger will stop at the point of the error you reported. I would examine the stack trace at that point to find where you've doubly-freed this memory.

Upvotes: 0

Marc Charbonneau
Marc Charbonneau

Reputation: 40507

NSInteger is a typedef for a primitive type, it's not an object that can respond to methods like retain or release. Even though it's named similarly to Cocoa classes like NSNumber or NSValue it's actually treated the same as int, float, etc.

Upvotes: 3

Alex Rozanski
Alex Rozanski

Reputation: 38005

No, an NSInteger is not an object; it is simply a typedef for an int (for 32-bit apps) or a long (for 64-bit apps):

#if __LP64__
typedef long NSInteger;
#else
typedef int NSInteger;
endif

Upvotes: 17

Related Questions