Martin Cox
Martin Cox

Reputation: 95

Viewing Cocoa Implementation Files in Xcode

This may be a really stupid question...

How do I go about viewing the implementation files for various classes within the Cocoa Touch framework? I can find the interface files pretty easily, but cannot find the implementation files.

I'm currently studying iOS development and have stumbled on the subject of returning autoreleased objects. I wanted to verify how this worked by studying the implementation within the framework classes. For example, using the NSArray class's convenience method 'arrayWithObjects' - I wanted to look at the mechanics of this method and see how it returned an autoreleased object etc.

Any ideas where I might find the implementation files?

Thanks

Martin

Upvotes: 0

Views: 302

Answers (2)

jscs
jscs

Reputation: 64022

As Eimantas says, you cannot view Apple's proprietary implementation files. I have occasionally found it helpful, however, to have a look at the GNUStep .m files (which Google can easily dig up for you). They obviously cannot be duplicates of Apple's implementations, but sometimes provide a little useful insight.

Upvotes: 0

Eimantas
Eimantas

Reputation: 49354

You can't view cocoa framework implementation files since code is owned by apple which definitely wouldn't want you to know what source they have written. And cocoa is not opensource (as well as mac os x).

As to mechanics of returning autoreleased object from any class' factory method - send an autorelease message to the object when returning it:

+ (id)myObjectWithParam:(id)param {
    MyClass *myObject = [[MyClass alloc] initWithParam:param];
    return [myObject autorelease];
}

Upvotes: 2

Related Questions