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 601
 
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.
Including the ones paired with other Macs on your network.
ArtOfWarfare is offline   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.
__________________
"Innovation distinguishes between a leader and a follower." : S.J.
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 offline   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 03:27 PM.

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

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC