New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
iOS Development Discussion on developing apps for the iOS platform.

Absolute beginner: How do I read this...


Post Reply New Thread Subscribe

 
Thread Tools
SaveMe

 
Member Since: Feb 14, 2013
Posts: 4
SaveMe is on a distinguished road

SaveMe is offline
I'm new to ios deveolpment, but have a little prior knowledge in programming .net 1.0/2.0.
Mij OOP skills are at beginner level still. I'm trying to learn to xcode using the book Objective-c for absolute beginners.

I struggle mainly with the syntax of objective-c. I'm learning class basics and ui basics.
An example from the book has me build an small app with just a label and a button. When the button is pressed, the label gets updated.

Now, in the viewcontroller.h file I define the following property:

Code:
@interface ViewController : UIViewController {
    IBOutlet UILabel *nameLabel;
}

- (IBAction)showName:(id)sender;
How do I read that line. The type is UILabel, the name is *nameLabel, but what is IBOutlet and why does that need to come in front of the property?

Also, in the implementation file the label is set in the showName method

Code:
- (IBAction)showName:(id)sender{
    [nameLabel setText:@"My name is ..."];
}
Why do I also need to link the label to the owner in the UI (xib file)?

Thanks for any answers!


EDIT:
I hope these beginners questions are okay here ...
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,729
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is online now
First, these questions are perfectly fine here..

IBOutlet and IBAction are special markers for Interface Builder. In code, they equate to nothing (nil in objective-c speak). They are used in your code to help IB figure out what to do.

IBAction allows the UI to send your code an message when a button is pressed, and IBOutlet allows the UI to pull data directly from code if need be.

So if your UI in IB had a button, you could have it send an action to something indicating it was pressed. IB would list the method showName: only when it sees the IBAction property before it.

All of this is part of MVC (Model View Controller) design pattern. The idea being that your data is held in the Model, the UI components in the View and a object that marshals stuff back and forth in the Controller.

This way the model (how you represent data) can change willy nilly while the view continues to look the same while displaying varying data depending on the model.

You will learn a lot more about this when you get to Deletgates and things like NSListView as an example..

--
Regards
...Ashwin



Be sure to read the Community Guidelines | The more information you provide, the better answers you get, remember GIGO.
QUOTE Thanks
SaveMe

 
Member Since: Feb 14, 2013
Posts: 4
SaveMe is on a distinguished road

SaveMe is offline
Thank you!

I guess I am confused because of my (little) knowledge of .Net
In .Net it suffices to update the labels text property using a method, as the showName method does. The extra steps of linking the two in the interface builder and declaring the label with the IBOutlet type are not necessary.

Guess i'll have to get the hang of it
QUOTE Thanks

Post Reply New Thread Subscribe


« Payment Processing Using PaymentExpress GateWay in iphone | Simple App Needs HELP »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
I Can Burn CD's, read others, but can't read my own blairalmm Apple Desktops 2 12-30-2009 12:58 AM
iTunes can't read my iPod Touch vbhacker iOS and Apps 8 10-29-2009 01:20 PM
Read TOC problem with the USB drive emulating like a CD-ROM drive(in MAC system) cychou Apple Notebooks 1 10-08-2009 08:45 AM
Mac HDD in a external enclosure doesn't give permission to read some files benio Other Hardware and Peripherals 2 01-30-2009 11:02 AM
Seagate 7200.10 incompatible? Detailed benchmarks! otheronenorehto Apple Desktops 5 01-15-2007 05:38 AM

All times are GMT -4. The time now is 11:28 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?