2

First of all, I already able to restore PPC support in Xcode 4 Snow Leopard using this article How do I add PPC/PPC64 support back to Xcode 4.2 under Lion?. But after sometimes, I realize that to make my current application (10.6, Snow Leopard) compatible with Tiger, I must modify some code. Especially about the synthesize & implement keyword. How do you deal with it? I enter Mac OS X programming by using X code 4, not using the previous version of it

And because @property is not supported in 10.4, is the IB Designer in Xcode 4 can still work if I am trying to make it compatible with Tiger?

Or, is it really that I must code using Xcode3 this way? * O o...

Thanks, Eko

Community
  • 1
  • 1
swdev
  • 4,997
  • 8
  • 64
  • 106
  • 1
    This is an sdk issue. Properties were introduced in 10.5, so you have a tough road ahead of you. Look at my answer below. – Jesse Black Oct 31 '11 at 07:16

1 Answers1

3

In objective-C the @property and @synthesize are neat shortcuts to implementing a getter/setter for a specific variable

Unfortunately you will need to stop using these.

You will need something like this

Example.h

@interface Example : NSObject
{
    NSObject * coolData;
}
@end

Example.m

@implementation Example
-(void)setCoolData:(NSObject*)newCD
{
    [newCD retain];
    [coolData release];
    coolDate = newCD;
}
-(NSObject*)coolData
{
    return coolData;
}
-(void)dealloc
{
    [coolData release];
    [super dealloc];
}
@end

And you will need to replace the code where you were accessing and setting the variables in question.

You don't need to do the release,retain methods for int's, float's ... (any primitive data that is not a pointer to an object)

For clarification

//assume number is defined in the header file     int number;

-(void)setNumber:(int)n
{
    number = n;
}
-(int)number
{
    return number;
}
Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Jesse Black
  • 7,966
  • 3
  • 34
  • 45
  • Yep! Thanks so much @Maudicus. I'll implement your verbose answer, and I'll report it here of what is the result. But, I was just thinking..it gonna be a very tedious task.. ah well, life is about works anyway :p – swdev Oct 31 '11 at 09:28