Im trying to get my head around Objective C and struggling fast. Im guessing what I am asking here is fairly rudimentary, but I cant seem to find the answers to my problems anywhere on StackOverflow, the Mac Developer Library or the internet in general.
Im trying to use the code from here: http://snipplr.com/view/23024/ to import an Image and display it.
UIGraphicsBeginImageContext
and
[img drawInRect:...]
are kicking up errors, namely “Unknown name type UIImage” and “No visible @interface for ‘UIImage’ declares the selector ‘drawInRect'”
Looking here I can find that drawInRect is a method of UIImage. Im guessing my problem is that the UIImage class cannot be found in my code.
So Im trying to include it, or import it – and Im just drawing a blank here – these lines of code dont work:
#import "UIImage"
#import "UIImage.h"
#include "UIImage"
#include "UIImage.h"
They kick out “file not found” errors. I have no idea how to locate these files, Im sure I am missing something really fundamental and simple, but cant find anything online that sheds any light on how to stop UIImage from being an “Unknown name type”.
Can anyone help?
Go to your project settings – select the target – Build Phases – Link Binary With Libraries and make sure Core Graphics and UIKit are linked. And also that UIKit is included in the header file, like Martin suggested.