ApplicationServices Framework

Nibbie
Posts: 2
Joined: 2009.01
Post: #1
I'm trying to write my first graphics application on the iPhone and I'm running into difficulties right off the bat. The first line:

CGContextRef context = UIGraphicsGetCurrentContext();

always returns nil for the context.

I suspect it's because I don't have the ApplicationServices framework installed so I added it. When I view it in the Add-Framework window it shows a size of 8k. I then add it and it appears in red. I look at it and it has a size of 0k. Strange!

The path is:

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/System/Library/Frameworks/ApplicationServices.framework

which I notice is different from the other frameworks which are in:

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/System/Library/Frameworks/

but I look there and I don't see ApplicationServices.

How do I load the correct ApplicationServices framework?
Quote this message in a reply
⌘-R in Chief
Posts: 1,260
Joined: 2002.05
Post: #2
1) Getting nil is not because you don't have ApplicationServices installed in your app. It's because there's no context to get.

2) You wouldn't "install" ApplicationServices, you'd "link against it."

3) UIGraphicsGetCurrentContext isn't in ApplicationServices, it's in UIKit.framework. ApplicationServices is a Mac framework, not iPhone.

4) If you weren't already linking against the framework that included the UIGraphicsGetCurrentContext function, your app wouldn't build and run.

Post more about where and when you call UIGraphicsGetCurrentContext.
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2009.01
Post: #3
Seth, thanks for the reply. I was definitely barking up the wrong tree and trying to solve a problem of my own creation.

You focussed me back in the right direction and I figured out problem. I'm now drawing like a champion! I appreciate your help.

Mick Brown
Quote this message in a reply
Post Reply