3

Well I am confused because should be a no brainer.

In Xcode 5 I start a new iphone project. In ViewDidLoad I begin typing:

NSImage *image ...

Actually at the point of "NSI" ... the NSImage is not available. I see many other options like NSInteger etc...

So from the start I cant create a NSImage object.

Ok so I look at documentation for NSImage and it clearly says object is declared in both following packages (why are there 2 declarations and which one should I use)

Declared in NSGraphics.h
NSImage.h 

but I am not allowed to import any of these packages.I just get red line next to it when I try to do that.

So if I am not allowed to import this package ... why does the documentation give me information about the package that it is in. I am sure I should be able to use it ??

So what daft thing am I doing ?

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
drlobo
  • 2,139
  • 5
  • 32
  • 42

1 Answers1

4

NSImage.h is an OS X class. You should be using UIImage, NSImage's iOS equivalent. This can get confusing considering a lot of the "NS" prefixed names are shared between iOS and OS X, but an easy way to determine what is available is to have a look at the iOS class references for Foundation.framework or UIKit.framework.

You can also expand the headers group in the frameworks group in Xcode's file inspector to see what headers are available to you.

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
  • so trying to read an image from a bundle like so : http://stackoverflow.com/questions/1659407/cocoa-problem-with-this-code-using-nsbundle there are lots of example of NSImage ? What is the difference why can they use it ? – drlobo Nov 18 '13 at 12:17
  • 1
    That question is about OS X development. – jrturton Nov 18 '13 at 12:19
  • 1
    Many thanks !! I thought I was going mad for a second :) (I am obviously still learning ios development) – drlobo Nov 18 '13 at 12:21
  • @drlobo Glad to hear this helped! Don't forget to mark as correct :) – Mick MacCallum Nov 18 '13 at 12:24