 |
 |
|
 |
02-06-2010, 08:04 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: Dec 2009
Posts: 36
|
UISegmented control dealloc crash
I got a crash log from my user. The "top" part of the log looks like this:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x000026f6 objc_msgSend + 18
1 UIKit 0x0011928c -[UISegmentedControl dealloc] + 12
2 CoreFoundation 0x00038f30 -[NSObject release] + 24
3 UIKit 0x00095c4c -[UIBarButtonItem dealloc] + 64
4 CoreFoundation 0x00038f30 -[NSObject release] + 24
5 UIKit 0x0008ec7a -[UINavigationItem dealloc] + 86
6 CoreFoundation 0x00038f30 -[NSObject release] + 24
7 UIKit 0x0009596c -[UIViewController dealloc] + 484
8 myApp 0x000041f6 -[myAppListViewController dealloc]
If I am reading this correctly, it has crashed trying to send a dealloc message to a segmented control (presumably the one I have on my navigation bar).
The relevant part of the segment control creation is:
NSString *strT = [self.dateformatUse stringFromDate:[NSDate date]];
NSString *strToday = [[[NSString alloc] initWithString:strT]autorelease];
NSArray *arSegments = [[NSArray alloc] initWithObjects:@"<",strToday,@">",nil];
UISegmentedControl *segctrlT = [[UISegmentedControl alloc] initWithItems:arSegments];
[arSegments release];
// set various segment control attributes
self.navigationItem.titleView = segctrlT;
self.segctrlTitle = segctrlT;
[segctrlT release];
in ViewDidUnload I have:
self.segctrlTitle = nil;
in dealloc for the view controller I have
[self.segctrlTitle release];
I am figuring either I shouldn't release (or rather should use autorelease) the components I use to build the segmented control in the creation part, or I shouldn't be setting it to nil in my ViewDidUnload routine. The crash is very elusive, so doing a "fix" and then testing it doesn't really work. I was hoping someone would see what I am doing wrong.
|
|
|
02-07-2010, 11:19 AM
|
#2 (permalink)
|
|
Will Work for Food!
Join Date: Apr 2009
Posts: 574
|
if you release it after you create it you dont need to release it again in the dealloc method.........
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 463 |
| 56 members and 407 guests |
| AlexTheMighty, alexy, aoredsson, arcturus, bbarlow641, benoitr007, BrianSlick, ChrisMayer, CunningCat, cye, davec2, davidcort, dbuddah, doblezeta, Dorald, dre, Duncan C, Ed99, elite, FerrariX, graph, HARDWARRIOR, harkonian, harrytheshark, howcr, iisword, iminichrispy, imsatasia, itzdark, Janek2004, javaconvert, jbro, JoshuaCaputo, landingham, LemonMeringue, MiniRobinho, Mr Jack, myPhone, rarindeed, robin1508, rocketman240, Rossco, rtrunck, Rudy, sayer, Son of a Beach, sorghum, tateyaku, Thaurin, ToM, TunaNugget, xiko, XXX, _nivek |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 24,136
Threads: 38,911
Posts: 170,717
Top Poster: smasher (2,565)
|
| Welcome to our newest member, cye |
|