Hi,
I have a variable called rootPage declared in projectViewController.h and its property has the attributes nonatomic and retain.
When the first line of loadItem runs, it passes rootPage (uninstantiated) as the first parameter (parent), the method checks if its nil, and in this case, sets parent to the previously instantiated SCItem item.
The problem is, when I place a break point on the line "int k = 0;", temp and rootPage both show as 0x0 (nil). However, I've placed a break point inside of the createItem method after parent has been set to item, and both show a pointer (data).
How do I make the changes made to parent inside of the createItem method change rootPage and not just some local variable copy inside of the method.
In my primary language (Visual Basic) you'd place ByRef in the parameter instead of ByVal, is there any similar thing here?
I have a variable called rootPage declared in projectViewController.h and its property has the attributes nonatomic and retain.
Code:
-(void)createItem:(SCItem *)parent:(NSString *)name {
SCItem *item = [[SCItem alloc] init];
item.name = name;
if (parent == nil) {
parent = item;
} else {
[parent.children addObject:item]; //ignore this
}
}
Code:
-(void)loadItems {
[self createItem:rootPage:@"Bookmarks"];
SCItem *temp = rootPage;
int k = 0;
}
The problem is, when I place a break point on the line "int k = 0;", temp and rootPage both show as 0x0 (nil). However, I've placed a break point inside of the createItem method after parent has been set to item, and both show a pointer (data).
How do I make the changes made to parent inside of the createItem method change rootPage and not just some local variable copy inside of the method.
In my primary language (Visual Basic) you'd place ByRef in the parameter instead of ByVal, is there any similar thing here?