Adding a category to UIImage in iPhone?

UIImage performStuff; // Correct call not UIImageView performStuff; // It is a UIImage category not UIImageView for starters So you would do something like this UIImage* image = UIImage imageNamed:@"test"; image performStuff.

UIImage performStuff; // Correct call not UIImageView performStuff; // It is a UIImage category not UIImageView for starters. So you would do something like this... UIImage* image = UIImage imageNamed:@"test"; image performStuff.

Thanks Jordan :), you're right :) – iPadDevloperJr Apr 9 at 12:24 1 -1: Not sure why this is getting votes. He clearly coded an instance method, not a class method. Your "correct call" is blatantly invalid.

– FreeAsInBeer Apr 9 at 12:41 @jordan is using class method syntax to illustrate the problem. – bentford Jul 19 at 21:59.

If the category is in the target project just include the DoingStuff.h. If inside a static library the linker will not link it in, because it doesn't know it should link objective c objects it doesn't know will be used. You need to put one of -all_load, -force_load or -ObjC in other linker options in you target project.

Different people report some or all of them make linker work. Starting with XCode 4 -ObjC should be enough. That said I didn't have success with any of them and ended in adding the categories from the library to the target project as references.

EDIT Just saw my mistake, probably it gets linked but is a instance method and you are calling it as a class method: not UIImage performStuff; but UIImage *image = ; image performStuff.

Thanks, Jordan answer my question. – iPadDevloperJr Apr 9 at 12:25 @iPadNewbie: What!? How did an incorrect answer "answer your question"?

– FreeAsInBeer Apr 9 at 12:49.

According to how you have your category set up, you would then need to call it like this: UIImage* myImage = UIImage imageNamed:@"testImage"; myImage performStuff; Additionally, you aren't following the naming conventions for categories. Your class name should be something more like "`UIImage+DoingStuff. H".

I would suggest refactoring it so that it's more clear to others that it's a category. And of course, you need to import the header file into the class you want to use it in: #import "DoingStuff.h.

In the process of finding the bug and posting the fix, I ended up writing a substantial amount of additional code to address various other annoyances related to UIImage. The complete listing is available for download below. Though it won’t solve the copy and paste problem, it should be a welcome remedy for other iPhone developers who have run into similar obstacles.

Programming for the iPhone, a highly graphical device, necessarily involves a substantial amount of image manipulation. Its SDK therefore provides an abstraction called UIImage that handles much of the effort in importing and drawing images. For example, imagine you want to load a JPEG file, scale it down to icon size, and give it rounded corners.

These tasks may require tens or even hundreds of lines of code on other platforms, but on the iPhone, it’s only a matter of instantiating a UIImage, passing it to a UIImageView of the appropriate size, and setting the cornerRadius property. Despite its ease of use, or perhaps because of it, UIImage suffers from some serious limitations. Key among these is its lack of support for resizing the image, a feature that is normally handled dynamically by its companion, the UIImageView component.

However, should an iPhone application need to reduce the size of an image for storage or for exchange with an external entity (such as a web server), the UIImage class is insufficient. Of course, UIImage is not the only means of image manipulation on the iPhone. It ships with a rather sophisticated graphics API, known as Quartz 2D, that offers low-level control of bitmap data.

Clearly, the functionality for resizing an image exists, although taking advantage of it is not straightforward and requires the developer to write non-trivial code.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions