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 01-23-2012, 11:34 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default Beyond bounds for empty array

I am trying to implement an inbox for rich notifications with xtify to my tab bar app. The code they use in example I adapted for my use to this:
Code:
- (UINavigationController *) setupPortraitUserInterface 
{
	UIWindow *localPortraitWindow;
	localPortraitWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.portraitWindow = localPortraitWindow;
	
	
	[localPortraitWindow release];
	
    [portraitWindow setBackgroundColor:[UIColor whiteColor]];
    
	
	tabBarController = [[UITabBarController alloc] init];
    tabBarController.delegate = self;
	localViewControllersArray = [[NSMutableArray alloc] initWithCapacity:5];
	
   
	UIViewController *inboxVC=[[XLappMgr get ]getInboxViewController];
	UIImage* iImage = [UIImage imageNamed:@"inbox.png"];
	inboxVC.tabBarItem.image = iImage;
	
	inboxNavController = [[UINavigationController alloc] initWithRootViewController:inboxVC];
    
	[localViewControllersArray insertObject:inboxNavController atIndex:1]; 
    [localViewControllersArray insertObject:thirdView atIndex:2];
    [localViewControllersArray insertObject:firstView atIndex:0];
    [localViewControllersArray insertObject:fourthView atIndex:3];
    [localViewControllersArray insertObject:fifthView atIndex:4];

   firstView= [[FirstViewController alloc] init];
	thirdView= [[ThirdViewController alloc] init];
	fourthView= [[FourthViewController alloc] init];
	fifthView= [[FifthViewController alloc] init];

	
	tabBarController.viewControllers = localViewControllersArray;
	
	[localViewControllersArray release];
	

	[portraitWindow addSubview:tabBarController.view];
	

	[portraitWindow makeKeyAndVisible];
	
	return inboxNavController;
    
    
   	
}
I get the error
Code:
[__NSArrayM insertObject:atIndex:]: index 1 beyond bounds for empty array'
Why is the array empty?
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 01-23-2012, 11:38 PM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Because you haven't added anything to it yet?

Instead of specifying an index, just add them in order like this:
Code:
[localViewControllersArray addObject:firstView];
[localViewControllersArray addObject:inboxNavController];
//etc..
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 01-23-2012, 11:55 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

[quote=Domele;403920]Because you haven't added anything to it yet?

Instead of specifying an index, just add them in order like this:
Code:
inboxNavController = [[UINavigationController alloc] initWithRootViewController:inboxVC];
    
	[localViewControllersArray addObject:inboxNavController]; 
        [localViewControllersArray addObject:firstView];
    [localViewControllersArray addObject:thirdView];
    [localViewControllersArray addObject:fourthView];
    [localViewControllersArray addObject:fifthView];
It now gives me the insertObject:atIndex cannot be set to nil. Nowhere in the whole file does it even have the code for insertObject:atIndex.
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 01-23-2012, 11:57 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Try cleaning, deleting the app, and rebuilding.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 01-24-2012, 12:02 AM   #5 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
Try cleaning, deleting the app, and rebuilding.
Same Issue
Code:
'*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 01-24-2012, 12:13 AM   #6 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

You need to allocate your controllers before you add them to the array.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 01-24-2012, 12:16 AM   #7 (permalink)
Registered Member
 
apatsufas's Avatar
 
Join Date: Jan 2011
Location: Thessaloniki, Greece
Posts: 121
apatsufas is on a distinguished road
Default

You need to initialize firstView,thirdView, fourthView, fifthView before you add them to the array.

Code:
[firstView= [[FirstViewController alloc] init];
thirdView= [[ThirdViewController alloc] init];
fourthView= [[FourthViewController alloc] init];
fifthView= [[FifthViewController alloc] init];
inboxNavController = [[UINavigationController alloc] initWithRootViewController:inboxVC];
    
[localViewControllersArray addObject:inboxNavController]; 
[localViewControllersArray addObject:firstView];
[localViewControllersArray addObject:thirdView];
[localViewControllersArray addObject:fourthView];
[localViewControllersArray addObject:fifthView];
__________________
SQLed - Your Database Manager on the go

iAZConverter - Converts everything from A to Z
apatsufas is offline   Reply With Quote
Old 01-24-2012, 12:29 AM   #8 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

Quote:
Originally Posted by apatsufas View Post
You need to initialize firstView,thirdView, fourthView, fifthView before you add them to the array.

Code:
[firstView= [[FirstViewController alloc] init];
thirdView= [[ThirdViewController alloc] init];
fourthView= [[FourthViewController alloc] init];
fifthView= [[FifthViewController alloc] init];
inboxNavController = [[UINavigationController alloc] initWithRootViewController:inboxVC];
    
[localViewControllersArray addObject:inboxNavController]; 
[localViewControllersArray addObject:firstView];
[localViewControllersArray addObject:thirdView];
[localViewControllersArray addObject:fourthView];
[localViewControllersArray addObject:fifthView];
Thanks to you both, that did it
__________________
My latest app...i Miss Mommy
spiderguy84 is offline   Reply With Quote
Old 01-24-2012, 01:46 PM   #9 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 920
spiderguy84 is on a distinguished road
Default

Well, I thought that fixed the problem. The app will run without terminating or giving errors, but it is just one big white screen, no tab bar controller or anything else.
__________________
My latest app...i Miss Mommy
spiderguy84 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: 395
11 members and 384 guests
7twenty7, Atatator, condor304, FrankWeller, glenn_sayers, iphonedevshani, MAMN84, mraalex, QuantumDoja, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

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