Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Sample iPhone plugin — Gideros Forum

Sample iPhone plugin

CarolineCaroline Guru
edited January 2012 in Code snippets
Available on github:

http://github.com/carolight/CBSamplePlugin

You need at least Beta 7 of Gideros Studio.
This sample contains a Gideros project called CBSamplePlugin and a CGSamplePlugin.mm file to be added to the GiderosiPhonePlayer app in Xcode. The project needs to be run on the iPhone device.

I haven't attempted a real life plugin example, just documented how to send and receive and iterate different types of data in 7 sample code pieces. The outputs of each are presented in both the Xcode debug console, and the Gideros Studio output console.

For a real life plugin, see gamekit, which comes with Beta 7.

I am new to Lua and C++ and github, and I don't understand everything yet, so if I have made any errors, or if there are better ways to do things, or if you have any questions, or any suggestions of further samples, please let me know.

Samples are:

1. Send two integers to the plugin to be added together and return an integer result

2. Send a string to the plugin. When the string is received, the plugin dispatches an event, returning a different string, which is picked up in Lua. (tricky :) )

3. Send a table with keys to an NSDictionary

4. Send a table array for sorting and return the sorted table array

5. Create a new table of localised day names in the plugin and return it to Lua

6. Similar to Sample 3 - create NSDictionaries of personData, this time saving the NSDictionaries in an array in the Objective C helper class. Return the array count and a pointer to the array using lightuserdata. Get a personData table back from the array using the array pointer.

7. Create a callback function, with variable arguments. This will be a Lua function called from the plugin.

I have not documented every C API function - the manual for the API is here:
http://www.lua.org/manual/5.1/manual.html#3

I found this discussion useful for concepts:
http://forums.tigsource.com/index.php?topic=22524.0
+1 -1 (+6 / -0 )Share on Facebook

Comments

Sign In or Register to comment.