I'm Delphi programmer and very new to Cocoa. at first I tried this :
-(void)awakeFromNib
{
int i;
NSString *mystr;
for (i=1;i<=24;i++)
{
[comboHour addItemWithObjectValue:i];
}
}
But it didn't work. Then I tried to search on Google but no luck. After experimenting about 30 min, I come with this:
-(void)awakeFromNib
{
int i;
NSString *mystr;
for (i=1;i<=24;i++)
{
mystr = [[NSString alloc]initWithFormat:@"%d",i];
[comboHour addItemWithObjectValue:mystr];
//[mystr dealloc];
}
}
My questions are:
- Is this the right way to do that ?
- Do I always need to alloc new NSString to change its value from integer ?
- When I uncomment [mystr dealloc], why it won't run ?
- Does it cause memory leak to alloc without dealloc ?
- Where can I find basic tutorial like this on internet ?
Thanks in advance