Sunday, January 12, 2014

xcode objective-c output problems


# Import

@ Interface Coordinate: NSObject

- (Void) setX: (int) x1;
- (Void) setY: (int) y1;
- (Int) getX;
- (Int) getY;

@ End


@ Implementation Coordinate {
int x;
int y;
}

- (Void) setX: (int) x1 {
x = x1;
}

- (Void) setY: (int) y1 {
y = y1;
}

- (Int) getX {
return x;
}

- (Int) getY {
return y;
}

@ End



int main (int argc, const char * argv [])
{

@ Autoreleasepool {

/ / Insert code here ...
Coordinate * myCoordinate;
myCoordinate = [Coordinate alloc];
myCoordinate = [myCoordinate init];

[MyCoordinate setX: 3];
[MyCoordinate setY: 5];

int a = [myCoordinate getX];
int b = [myCoordinate getY];

NSLog (@ "my coordinate is x =% i, y =% i", a, b);
}
return 0;
}

Why is this code in xcode output (11db)? Where is the problem ah. . . I know that might be set a little method in question, but could not find any problems. Thank you seeking answers!
Reply:
Well if you can (11db) This is an error it? I am a novice objective-c. . .
Reply:
. . . Strange
Reply:
My xcode version is 4.6.3
Reply:
 myCoordinate = [Coordinate alloc]; 
myCoordinate = [myCoordinate init];


Use the above code to instantiate an object, the object may not have a lot of what we want. The official recommended way is to use alloc init chain created
myCoordinate = [[Coordinate alloc] init];
The reason: Even if the object can not be created successfully, will return nil, the most important reason is that the object pointer is returned by the init, rather than alloc

Reply:
NSLog (@ "my coordinate is x =% i, y =% i", a, b);
Shaping it with% d. . .
Reply:
4th Floor, hello, thank you for your answer, but I also tried this approach you, or I may appear above problems
Reply:
The need for this kind of grammar tangled it? Write more you understand
Reply:
You are using a XCODE5 it, change it AUTO

Reply:
You will not use synthetic accessor it! Look at the book,. M and. H horse head right horses mouth

Reply:
I already know the error, the code is no problem, the problem is too set on xcode

No comments:

Post a Comment