Plugin iOS import Objective-C Category (Extension for UIImage)

ios

#1

Hi

We’re trying to write a plugin for a native iOS library. I need to use a function on UIImage which is part of a Objective-C Category - this works natively only if you import the extension in your class.

How can I import an Objective-C category in nativescript?

Cheers


#2

Anytime you can access a UIImage instance of {N} Image in iOS by image.ios (or image.nativeView).

So can you give more spec on what exactly you are trying to implement on UIImage.


#3

OK so I’m writing a plugin to integrate a iOS library to scan images. So I’m writing Objective-C in JavaScript as you have to when you develop platform specific plugins.

I want to apply a filter on the UIImage I get from the library, the library provides filters to optimize the image. These optimization is programmed as a so called category in objective-c. A category you can compare like extension methods for existing types. The allows you to call methods on UIImage which are not part of the iOS SDK. To use this functionality in iOS natively you have to import the header of this category e.g. (#import “UIImage+MyCategoryExtension.h”)

So this is the basic question, is it possible to add an import statement in nativescript or how can I import a category class. Because when I call a method from the Category it cannot be found on runtime.


#4

First that should be possible in NativeScript. Secondly, I don’t think everything is done in your library with an import statement. If I’m not wrong your library may extend UIImage, may be with few delegates. Still all that should be possible with {N}.

But until I can see some code piece, can’t say much.