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 603
 
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 68030
 
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

Similar Threads
thread Thread Starter Forum Replies Last Post
Endnote X7 "Cite while you write" not working EddyBolt Mac Basics and Help 0 Nov 13, 2013 10:19 PM
Can't restore iPod - "unable to write to the last block of the device" dawnchorus iPod 2 Aug 9, 2013 06:25 PM
Write up about "creative process" during game development comicool iPhone and iPod touch Apps 0 Sep 11, 2012 01:06 AM
What happens when you enter an incorrect "defaults write" command? bitfidelity OS X 2 Jul 28, 2012 04:44 PM
DL DVD+R "Failed to Burn...Medium Write Error" KyleMacs MacBook Pro 1 Jun 13, 2012 11:49 AM

Forum Jump

All times are GMT -5. The time now is 06:30 AM.

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

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