Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 21, 2013, 09:53 AM   #1
JacekK
macrumors newbie
 
Join Date: Jan 2013
How to write it without "@"

I have a code lie this:

Code:
    // Initialize List View Controller
    MTListViewController *listViewController = [[MTListViewController alloc] init];
    // Initialize Navigation Controller
    UINavigationController *listNavigationController = [[UINavigationController alloc] initWithRootViewController:listViewController];
    // Initialize Tab Bar Controller
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    // Configure Tab Bar Controller
    [tabBarController setViewControllers:@[listNavigationController]];
its code from tutorial i am doing right now, i have old version of xcode (4.2) and this is not working:

Code:
[tabBarController setViewControllers:@[listNavigationController]]
How can i write it without using "@"
JacekK is offline   0 Reply With Quote
Old Jan 21, 2013, 10:50 AM   #2
ArtOfWarfare
macrumors 68040
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
The @ signifies an Obj-C literal. In this case, what you specifically want is an NSArray literal.

To get this same NSArray as a non-literal, you can do:

Code:
NSArray *navigationControllerArray = [NSArray arrayWithObject:listNavigationController];
[tabBarController setViewControllers:navigationControllerArray animated:NO];
Also, note that there isn't a method for UITabBarController called setViewControllers:, it's called setViewControllers:animated:...
__________________
Battery Status - On the Mac App Store
The only app that'll estimate when your wireless devices will need their batteries changed.
Like it on Facebook!
ArtOfWarfare is online now   1 Reply With Quote
Old Jan 21, 2013, 01:37 PM   #3
KoolStar
macrumors Demi-God
 
KoolStar's Avatar
 
Join Date: Oct 2006
Location: Kentucky
Send a message via AIM to KoolStar Send a message via Skype™ to KoolStar
Quote:
Originally Posted by ArtOfWarfare View Post
The @ signifies an Obj-C literal. In this case, what you specifically want is an NSArray literal.

To get this same NSArray as a non-literal, you can do:

Code:
NSArray *navigationControllerArray = [NSArray arrayWithObject:listNavigationController];
[tabBarController setViewControllers:navigationControllerArray animated:NO];
Also, note that there isn't a method for UITabBarController called setViewControllers:, it's called setViewControllers:animated:...
If you have multiple object you would have to use arrayWithObjects just an FYI.
__________________
2.4 MacBook Aluminum 480GB SSD/750GB Optibay 8GB RAM CE | MacBook 2.4 SR 4GB, 320GB HD | PB G4 1.67 | 15 TiBook-DVI 800
iPhone 4S 16GB | iPhone 5 32GB
KoolStar is offline   0 Reply With Quote
Old Jan 21, 2013, 05:11 PM   #4
PhoneyDeveloper
macrumors 68020
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
OP (and ArtOfWar), if you look at the UITabBarController header you'll find the relevant property:

Code:
@property(nonatomic,copy) NSArray *viewControllers;
That's the method you're using so the required parameter is an array of view controllers.
PhoneyDeveloper is online now   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump


All times are GMT -5. The time now is 06:05 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC