You should definitely read the free ObjC.pdf that Apple provides, as it should help clear up some confusion here.
But basically, Objective-C is a struct superset of C, without any ambiguity between primitive types and ObjC classes. Objects in ObjC are always created on the heap, rather than the stack, and as such they always require a pointer. Thus, you can never declare a string like: NSString string; but instead you must always declare it as NSString* string; since it is a pointer to an NSString object in memory.
(This is true even for short-lived temporary objects, which at first confused me greatly. To create a temporary object for the method you're in, you can simple do: MyObject* object = [[[MyObject alloc] init] autorelease]; in most cases. The -autorelease method is what makes it a temporary objects for you, even though it's created on the heap. Read more about memory management to learn about this. But I've digressed, that's a Cocoa topic more than an Objective-C topic.)
On Fri, Mar 5, 2010 at 11:09 AM, Marx Bievor <email@hidden> wrote:
thank you. You were right, I used int* instead of int.. The warning has gone. Thank you!
But that makes me wonder whether I understood object* vs object correctly. Apparently not. Could you please give me a brief explanation what the difference is? Is *used for objects, while without *, is it something like a primitive data type in java?
Am 05.03.2010 um 17:01 schrieb Steven Degutis:
This warning pops up when you're assigning, as the warning says, a value of one type to a variable of another type. Having not yet seen your header file, I can't be 100% certain of this, but the warning strongly indicates that your "age" instance-variable (or ivar) is in fact *not* typed as "int", but as some kind of pointer, perhaps as int* for example. But it's hard to say without seeing your header file (I'm sure you understand why we can't just take your word for it, and why we need to see the code verbatim).
On Fri, Mar 5, 2010 at 10:53 AM, Marx Bievor <email@hidden> wrote:
I'm relatively new to the objC language, that's why I would be very happy if you could help me.
The compiler gives me the following build warning (the code compiles and I can run my app just fine, but I'm curious to know which line of code causes this behavior): "Assignment makes pointer from integer without a cast". The error occurs in the line "age = newAge"... I declared age as an int in the .h file.
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden