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 > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-20-2009, 10:05 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 51
anmldr is on a distinguished road
Default ObjC syntax

I am trying to understand what a star is used for... *

In the first after NSEvent there is a * and closed parenthesis. In the second, there is no star. It is hard to look up "*" in any documentation.

-(void)mouseDown: (NSEvent *)event {
//my code
}

-(void)drawRect: (NSRect)rect {
//my code
}

Thanks,
Linda
anmldr is offline   Reply With Quote
Old 06-21-2009, 01:48 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2008
Location: Denver
Posts: 172
BSDimwit is on a distinguished road
Default Objects....

Quote:
Originally Posted by anmldr View Post
I am trying to understand what a star is used for... *

In the first after NSEvent there is a * and closed parenthesis. In the second, there is no star. It is hard to look up "*" in any documentation.

-(void)mouseDown: (NSEvent *)event {
//my code
}

-(void)drawRect: (NSRect)rect {
//my code
}

Thanks,
Linda
I may be bad at explaining it, but my understanding of how this works is that the *asterisk is used when declaring or referring to Objective C Objects. It isn't used when declaring things like int, double, float, NSRect (c struct), and the like. So if that thing you are declaring is an object, like an NSString, NSArray, UITableView (objects) use the asterisk, but when you are declaring C primitives such as int, double, float, etc... (primitives might not be the right word). The only exception I've seen regarding this rule is when you declare and object that is of the type "id" which is like a catch all object.

I think the *asterisk means that it's pointing to a location in memory of where that object will reside.

Someone will probably correct my explanation, but if you follow the rules I basically listed above, you won't go wrong.

Last edited by BSDimwit; 06-21-2009 at 01:53 AM.
BSDimwit is offline   Reply With Quote
Old 06-21-2009, 07:58 AM   #3 (permalink)
Former NeXTStep Developer
 
Join Date: Mar 2009
Posts: 997
FlyingDiver will become famous soon enough
Default

It's means it a pointer. (NSEvent *) means pointer to an NSEvent object. (NSRect) mean just an NSRect data type (which is actually a struct, IIRC).

Object types are almost always referred to by a pointer, which simple data types are not.

joe
FlyingDiver is offline   Reply With Quote
Old 06-21-2009, 09:39 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 51
anmldr is on a distinguished road
Default

Thank you BSDimwit and Joe.

BSDimwit I like your less than accurate explanation. I actually understood what you were describing. Joe's was more exact but together I truly get the concept now.

Linda
anmldr 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: 454
16 members and 438 guests
Domele, Duncan C, Feldspar, karatebasker, MacBook MH, Objective Zero, patapple, Paul Slocum, peterwilli, pipposanta, PixelInteractive, Punkjumper, rubyeim54, SLIC, taylor202, Today's Posts
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,694
Threads: 94,137
Posts: 402,950
Top Poster: BrianSlick (7,990)
Welcome to our newest member, peterwilli
Powered by vBadvanced CMPS v3.1.0

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