 |
 |
|
 |
04-11-2009, 09:46 PM
|
#1 (permalink)
|
|
New Member
Join Date: Apr 2009
Posts: 5
|
Dot Syntax
Fairly newbish question that has been plaguing me for some time now.
I have a class called "Board"
Here is the Interface:
Code:
@interface Board : NSObject
{
int width;
int height;
int numCells;
SpawnPoint *spawnPoint;
Cell *endPoint;
NSMutableArray *cells;
}
I have another class "PathNodeManager"
Code:
@interface PathNodeManager : NSObject
{
@private
NSMutableArray *pathNodes;
Board *gameBoard;
}
@implementation PathNodeManager
- (id)initWithGameBoard: (Board *) newGameBoard
{
self = [super init];
if( self !=nil )
{
self.gameBoard = newGameBoard;
for( int i=0; i<self.gameBoard.numCells; i++)
[self.pathNodes addObject:nil];
}
return self;
}
Now here is the question. When I use self.gameBoard I cannot use auto completion. However, if i just type "gameBoard" auto completion works fine. It seems that dot syntax does not like the "self." in front of it. My understanding is that you should always refer to member variables with a "self.". Should I just give up on dot syntax all together?
Thanks,
Jacob
|
|
|
04-11-2009, 09:57 PM
|
#2 (permalink)
|
|
Former NeXTStep Developer
Join Date: Mar 2009
Posts: 996
|
Is it just the editor autocompletion that's bothering you, or is the code actually working differently?
The dot syntax you're using is normally used to invoke the compiler generated setter/getter methods that are created when you use @property/@synthesize. Since you don't have those, the editor is probably somewhat confused. Looks like the compiler doesn't care (unless you're getting errors you haven't mentioned).
joe
|
|
|
04-11-2009, 10:02 PM
|
#3 (permalink)
|
|
New Member
Join Date: Apr 2009
Posts: 5
|
Sorry, I left out the @property/@synthesize from the code I linked. I have a
@property (retain) Board *gameBoard;
and
@synthesize gameBoard;
Yeah the only issue is xcode not auto competing. Everything compiles and runs fine. I just find it weird that xcode would not auto complete if I add self. onto one of my member variables.
Quote:
Originally Posted by FlyingDiver
Is it just the editor autocompletion that's bothering you, or is the code actually working differently?
The dot syntax you're using is normally used to invoke the compiler generated setter/getter methods that are created when you use @property/@synthesize. Since you don't have those, the editor is probably somewhat confused. Looks like the compiler doesn't care (unless you're getting errors you haven't mentioned).
joe
|
|
|
|
04-11-2009, 10:12 PM
|
#4 (permalink)
|
|
Former NeXTStep Developer
Join Date: Mar 2009
Posts: 996
|
Quote:
Originally Posted by jacobhb
Sorry, I left out the @property/@synthesize from the code I linked. I have a
@property (retain) Board *gameBoard;
and
@synthesize gameBoard;
Yeah the only issue is xcode not auto competing. Everything compiles and runs fine. I just find it weird that xcode would not auto complete if I add self. onto one of my member variables.
|
Auto-completion is flaky, IMHO.
joe
|
|
|
04-12-2009, 03:19 AM
|
#5 (permalink)
|
|
New Member
Join Date: Apr 2009
Posts: 5
|
Quote:
Originally Posted by FlyingDiver
Auto-completion is flaky, IMHO.
joe
|
Thanks for the reply, I just wanted to make sure I was not doing something wrong.
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 478 |
| 34 members and 444 guests |
| acegames, Akshay Shah, baxtercr, beginer2007, danny8, eyefone, fede, gabacus, harikant_jammi, hveveris, ianian, Iphonica, jackson, jdavid, joelm, kikesantos, kilobytedump, m4r0ck, mcwhite, mgales, mobilesoftware, Mr Jack, mxstudios, NSeven, raees, raziiq, refreshe, riq, scalar, shweta13, supudo, theM, tin pot, wolfenberg |
| Most users ever online was 779, 05-11-2009 at 10:55 AM. |
» Stats |
Members: 21,478
Threads: 35,762
Posts: 156,660
Top Poster: smasher (2,448)
|
| Welcome to our newest member, m4r0ck |
|