简体   繁体   中英

calling js from obj-c openfeint

I can call js from obj-c from the phonegap plugin classes and the main app delegate class as follows: [webView stringByEvaluatingJavaScriptFromString:@"alert('Hello');"];

You can do this because the webView object can be handled by the phonegap plugin classes and the phonegap main app delegate.

However I am integrating Openfeint and it has many of its own classes. When I try the above code in an Openfeint delegate class it doesn't work because the Openfeint delegate classes can't get a handle on the webView object.

Can anyone tell me how to do this? I've tried messing with the class interfaces and importing .h files in various places but nothing seems to be working. Obviously webView is sitting there somewhere.

I am hacker of obj-c as opposed to someone who really understands it.

I have gotten achievements and leaderboards working for my app. This is relatively straight forward. USers can also create and send new challenges.

But I cannot get users who receive these challenges to play them because of the problem above (at least that's my theory).

I'll share all my Openfeint know how once I get this problem sorted and release my app.

Cheers

Nigel

I think you can safely reduced your problem to a simple one. Passing the webview object to Openfeint-classes, or may be a single super class. (I have never used openfeint and if this isn't the problem, then please don't read further)

These are two different questions on stackoverflow related to sharing/passing a variable among classes. There may be more, and you can search for what suits your requirements on these lines.

Passing variables through classes in Objective-C

How do I pass variables between view controllers?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM