Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-06-2010, 09:04 PM   #1 (permalink)
BrianMu
Registered Member
 
Join Date: Dec 2009
Posts: 36
Default 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.
BrianMu is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,866
Threads: 89,223
Posts: 380,689
Top Poster: BrianSlick (7,129)
Welcome to our newest member, sethaver
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:01 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.