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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-06-2011, 01:34 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Phoenix, AZ
Posts: 71
DanielMedia is on a distinguished road
Default Objects from App Delegate empty in iOS5

My app works fine in all versions of iOS4. However in iOS5, there seems to be a problem with how my code is getting objects from the app delegate.

iShadowBoxerAppDelegate *appDelegate = (iShadowBoxerAppDelegate *)[UIApplication sharedApplication].delegate;
NSMutableArray *globalFootwork = [appDelegate footwork];

In iOS 4 this works fine and loads a mutable array with objects from the app delegate. In iOS5 the mutable array is empty. Here is how the mutable array is setup in my app delegate:

(in my AppDelegate.h)

@property (nonatomic, retain) NSMutableArray *footwork;

(in my AppDelegate.m)

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions {

NSMutableArray *newFootwork = [[NSMutableArray alloc] init];
[self setFootwork:newFootwork];
[newFootwork release];

(I then add objects to self.footwork)

}

I'd appreciate any help with this. Thanks.
DanielMedia is offline   Reply With Quote
Old 11-06-2011, 01:44 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Nothing wrong here. There must be some other issue. Add logs, see what's happening.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 11-06-2011, 01:53 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Phoenix, AZ
Posts: 71
DanielMedia is on a distinguished road
Default

Thanks Slick.

Ok, maybe I'm not very iOS5 savvy but this seems very weird to me. I put a breakpoint in my application delegate and one in the controller which calls my application delegate.

If I load up the iOS4 simulator, the first breakpoint encountered is in my app delegate. If I load up the iOS5 simulator, the first breakpoint encountered is in the calling controller. Not the app delegate. Shouldn't the app delegate always load first? Weird...
DanielMedia is offline   Reply With Quote
Old 11-06-2011, 01:57 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Are you sure you're talking about a fresh launch and not a resume?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 11-06-2011, 02:01 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Phoenix, AZ
Posts: 71
DanielMedia is on a distinguished road
Default

I deleted the app from the iPhone simulator(iOS5) and ran a fresh install. The breakpoint in the app delegate never gets called in iOS5. It does in iOS4 though.
DanielMedia is offline   Reply With Quote
Old 11-06-2011, 02:03 PM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Add logs.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 11-06-2011, 02:09 PM   #7 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by DanielMedia View Post
I deleted the app from the iPhone simulator(iOS5) and ran a fresh install. The breakpoint in the app delegate never gets called in iOS5. It does in iOS4 though.
Odd.

I'm grasping at straws here. Does your app delegate have a applicationDidFinishLaunching: method as well as an applicationidFinishLaunchingWithOptions:?

I believe that, for compatibility, the system will call the old style applicationDidFinishLaunching: method first if you have both.

Try adding an init method to your app delegate and setting a breakpoint on that.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 11-06-2011, 02:28 PM   #8 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Phoenix, AZ
Posts: 71
DanielMedia is on a distinguished road
Default

I found out what was going on. In iOS5 the flow of execution seems to work a little differently.

When I did this in iOS4 it worked:

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions {

[window makeKeyAndVisible];
[window addSubview:tabBarController.view];

[self loadMoves];

}

But in iOS5 I have to load the moves first and THEN load the tab bar.

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions {

[self loadMoves];

[window makeKeyAndVisible];
[window addSubview:tabBarController.view];

}

Was that just a dumb mistake on my part? Is it better to always load data PRIOR to setting the main view?

BTW, Thanks guys for the help : )
DanielMedia is offline   Reply With Quote
Old 11-06-2011, 02:31 PM   #9 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

I tend to make the view the last thing that happens. Kinda makes sense that way if you think about it. I do the makeKeyAndVisible dead last, too.

You probably also want to switch to using the rootViewController property of the UIWindow.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 11-06-2011, 02:39 PM   #10 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Phoenix, AZ
Posts: 71
DanielMedia is on a distinguished road
Default

Thanks Brian.

Here's what I changed it to according to your recommendations:

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions {

[self setDefaultSettings];

[self startAudioSession];

[self loadMoves];

[window setRootViewController:tabBarController];

[window makeKeyAndVisible];

return YES;

}
DanielMedia is offline   Reply With Quote
Old 11-06-2011, 02:41 PM   #11 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Yep. The only catch will be if those first 3 items could take too long. Your app might get killed. If that's the case, then you'll want to do them in the background or after a delay, and you'll have to tweak the view controllers for that possibility.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 11-06-2011, 02:47 PM   #12 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Phoenix, AZ
Posts: 71
DanielMedia is on a distinguished road
Default

I will do some testing on my devices and see if that will be an issue. Thanks again for your help Brian. I appreciate it!
DanielMedia is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 407
17 members and 390 guests
7twenty7, Alex-alex, Apptronics RBC, baja_yu, dre, gwelmarten, ipodphone, jeroenkeij, jleannex55, matador1978, mbadegree, n00b, pbart, reficul, Retouchable, Sami Gh, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:22 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0