1

My requirement is: I need to initialize a specific objective-c class and call its method from javscript using UIWebview like below eg:

I have an objective-c class called "Calculator" which has the following methods

@interface Calculator : NSObject {
}
@property (nonatomic, retain) start;
@property (nonatomic, retain) add:(NSInteger) a with:(NSInteger) b;
@property (nonatomic, retain) subract:(NSInteger) a by:(NSInteger) b;;

@end;

I have a UIWebview, in which I am loading HTML with JS. Here, I have a JS script function like

function callNativeClass() {

window.calc.start;

}

"calc" is the instance or namespace of the class. I need to call the start method from JS.

Can you please tell me, is there any option to call native objective-c class like PhoneGap?

1 Answer 1

1

Phonegap does this. Download the framework from phonegap.com. You can create a custom plugin very easily to call the methods in Objective C file. Try this

http://wiki.phonegap.com/w/page/36753496/How%20to%20Create%20a%20PhoneGap%20Plugin%20for%20iOS

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.