Re: Well I am new to Objective-C
Re: Well I am new to Objective-C
- Subject: Re: Well I am new to Objective-C
- From: Alastair Houghton <email@hidden>
- Date: Sun, 2 Aug 2009 11:41:03 +0100
On 2 Aug 2009, at 10:35, Agha Khan wrote:
I have a point to an object but some API's need only object. How can
I convert pointer to an object.
This is an Objective-C question and as such really belongs either on
objc-lang or cocoa-dev; either way, it has nothing to do with Xcode.
That said, it's a simple question to answer; in Objective-C, you
*always* use a pointer to an object; you *never* refer directly to an
object like you might in C++ for e.g. stack-based objects.
If you think that an API is taking an object object argument rather
than a pointer to an object, you've misread it.
As for the code below:
NSString* ImageName = "BigBang.png";
This would generate a warning, because "BigBang.png" is a C string and
not an NSString. You want @"BigBang.png" instead.
I have a pointer to a string (Image file name) , but [UIImage
imageNamed:FileName];
I haven't looked at the docs for +[UIImage imageNamed:], but it will
take a *pointer* to an NSString I should think. If you're reading
prose in the docs, it may say that it "takes an NSString argument",
but it really means a pointer to an NSString... since *all* ObjC
objects are referred to via pointers, it's conventional not to bother
mentioning that it's a pointer every time.
(If you've done any Java, it's vaguely similar there, except that Java
isn't explicit about the fact that variables of object type are really
pointers/references---it's just assumed that you realise that fact.)
Finally, *please* can you pick a more helpful subject line when
posting to mailing lists. "Well I am new to Objective-C" tells us
nothing about what your post was about; something like "Do Cocoa Touch
APIs take pointer arguments?" would have been a better choice. Many
of us are signed up for a lot of mailing lists and it helps us to scan
through them for messages we're interested in or might usefully be
able to help out with.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden