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 09-15-2010, 04:28 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 3
masterrex is on a distinguished road
Default n00b question, I'm sure..

TL;DR
I can't seem to populate a UILabel from the viewDidLoad method.
----------------------------------------
Basically, I'm using a root view controller to generate a UITableView / populate it with data from an NSArray (which, in this case uses a plist as a data source).

Each table element links to a new view controller, and at this point in the logic I pull data from the plist (as it's already being accessed to generate the table) and pass it to the view being called.

So I'm passing the data doing this:
exampleController.stringText = [dictionary objectForKey:@"someData"];

In the example controller, I'd like to push the string data into an existing UILabel. However, it only seems to work if I attach it to an IBAction, such as:

-(IBAction)doSomething {
NSString *label = stringText;
IBOutlet label.text = label;
}

And does NOT work if I put those two lines in the viewDidLoad method, which would be ideal (setting the label text on view load without buttonpress or whatever).

What am I missing?

Btw, I'm declaring the NSString *label, UILabel *label in the header, and using properties for 'em, and synthesizing the stringText and label in the implementation file.

This is all very new to me, I'm used to working in Perl/PHP!
*hides in flame suit*

Thank you!
Rex
masterrex is offline   Reply With Quote
Old 09-15-2010, 06:24 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 4
DaTa is on a distinguished road
Default

maybe you could put it into method -(void)viewDidAppearBOOL)animated ?

or maybe you are setting that stringText after the viewDidLoad finishes? you should try to put some debugging NSLogs to that method...

but it's also strange, that you are declaring NSString *label and UILabel *label in the same header file? I don't think so... But anyway, why make life more complicated by naming your local variables same as your class variables?
DaTa is offline   Reply With Quote
Old 09-16-2010, 09:26 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 3
masterrex is on a distinguished road
Default

Quote:
Originally Posted by DaTa View Post
maybe you could put it into method -(void)viewDidAppearBOOL)animated ?

or maybe you are setting that stringText after the viewDidLoad finishes? you should try to put some debugging NSLogs to that method...

but it's also strange, that you are declaring NSString *label and UILabel *label in the same header file? I don't think so... But anyway, why make life more complicated by naming your local variables same as your class variables?
<333

Apparently I don't know the difference between the predefined methods. Thank you! Using viewDidAppear worked!

------------------

Now... if I add multiple labels to a view controller, how do I specify between them in code? I'm sure there's an attribute I set somewhere in Interface Builder, and there's some way to specify which UILabel I'm talking about... but how? o.O

Last edited by masterrex; 09-16-2010 at 09:32 AM. Reason: Additional question...
masterrex is offline   Reply With Quote
Old 09-16-2010, 10:57 AM   #4 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 3
masterrex is on a distinguished road
Default

Nevermind, apparently I already knew how and just didn't try. :P
masterrex 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: 331
19 members and 312 guests
2ndSegment, bignoggins, cayladv57, cgokey, dermotos, djohnson, Domele, guusleijsten, Hamad, heshiming, linkmx, markuschow, Objective Zero, pungs, Rudy, Sloshmonster, teebee74, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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