hai,
in java, 'this' is a keyword that refers to the object on which the method containing the keyword 'this' is invoked.when we assign any value to 'this'
this = null;
it shows compile time error: CANNOT ASSIGN VALU TO FINAL VARIABLE 'this'
However, in Objective C, if i assign
self = nil;
it accepts.
Can anyone explain what happens as a result of this.
Example:
/*_____________main()_______________________*/
int main()
{
id OBJ_Alpha;
OBJ_Alpha = [[Alpha alloc]init];
[OBJ_Alpha SomeMethod];
[OBJ_Alpha PrintMethod]; //is this line equivalent to [nil PrintMethod]?
}
/*__________________class Alpha_____________________*/
@implementation Alpha
{}
-(void)SomeMethod
{
self = nil;
}
- (void) PrintMethod
{
printf("I am alive!!!");
}
@end
/*__________________________Example ends_____________*/
Will the PrintMethod work?
in java, 'this' is a keyword that refers to the object on which the method containing the keyword 'this' is invoked.when we assign any value to 'this'
this = null;
it shows compile time error: CANNOT ASSIGN VALU TO FINAL VARIABLE 'this'
However, in Objective C, if i assign
self = nil;
it accepts.
Can anyone explain what happens as a result of this.
Example:
/*_____________main()_______________________*/
int main()
{
id OBJ_Alpha;
OBJ_Alpha = [[Alpha alloc]init];
[OBJ_Alpha SomeMethod];
[OBJ_Alpha PrintMethod]; //is this line equivalent to [nil PrintMethod]?
}
/*__________________class Alpha_____________________*/
@implementation Alpha
{}
-(void)SomeMethod
{
self = nil;
}
- (void) PrintMethod
{
printf("I am alive!!!");
}
@end
/*__________________________Example ends_____________*/
Will the PrintMethod work?