Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 18    Views: 69

Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
04/17/13 05:08 PM (12 years ago)

JSON Question: Loading Screens

Hi All, I am trying to make a plugin: iOS. This plugin will have 3 buttons. What code would I use so when the user clicks the button, the button would load another BT screen. How do I get the JSON from the config.txt? Thanks, Jake
 
aussiedra
Code is Art
Profile
Posts: 431
Reg: Dec 25, 2010
Brisbane, Austr...
8,260
like
04/17/13 05:41 PM (12 years ago)
you would have the item in your bt config file like : bttn1 if([[thisMenuItem jsonVars] objectForKey:@"bttn1"]){ >>>insert function coding<<<< }
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/17/13 05:50 PM (12 years ago)
Not exactly true. You can dynamically create a screen without it being in the config.txt file already. See my post about half way down in the following thread for how to accomplish this going from a modified menu plugin to a Email plugin: https://www.buzztouch.com/forum/thread.php?tid=64A97C87E9AD0EABAAE26EA&fid=BC70C36A743CD4FAD95D17F&sortColumn=FT.id&sortUpDown=DESC&currentPage=1
 
aussiedra
Code is Art
Profile
Posts: 431
Reg: Dec 25, 2010
Brisbane, Austr...
8,260
like
04/17/13 05:55 PM (12 years ago)
oops just was responding to "How do I get the JSON from the config.txt?"
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
04/17/13 06:54 PM (12 years ago)
So here is the screenshot of the error: http://jworldhosting.com/Uploads/Images/UIAlertError-JSON.png Here is the plugin code: http://jworldhosting.com/Uploads/jc_UIAlert-b1.zip I am trying to get NSLog(@"Button 2 was selected."); to load a screen when tapped. Thanks, Jake
 
aussiedra
Code is Art
Profile
Posts: 431
Reg: Dec 25, 2010
Brisbane, Austr...
8,260
like
04/17/13 07:34 PM (12 years ago)
you need to define screenObjectToLoad
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
04/17/13 08:03 PM (12 years ago)
When I add: BT_item *screenObjectToLoad = nil; The compiler is not happy. Do you have any suggestions on where and what to add to define it? Jake
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/17/13 08:12 PM (12 years ago)
//You need to both initiate the object: BT_item *screenObjectToLoad = [[BT_item alloc]init]; //and load it with some data: screenObjectToLoad.itemId = @"someRandomIDHere"; screenObjectToLoad.itemNickname = @"aGenericNickname"; screenObjectToLoad.itemType = @"nameOfClassFileWithoutDotM"; NSMutableDictionary *tmpJsonValues = [[NSMutableDictionary alloc]init]; [tmpJsonValues setObject:@"someRandomIDHere" forKey:@"itemId"]; [tmpJsonValues setObject:@"aGenericNickname" forKey:@"itemNickname"]; [tmpJsonValues setObject:@"nameOfClassFileWithoutDotM" forKey:@"itemType"]; [tmpJsonValues setObject:@"someJSONValue" forKey:@"someOtherJSONKey"]; screenObjectToLoad.jsonvars = tmpJsonValues; //then release the objects you don't need any more [tmpJsonValues release]; //add some code here //...code... //release main BT_item [screenObjectToLoad release];
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/17/13 08:13 PM (12 years ago)
haven't actually loaded that into XCode to test it out, but it should work just fine. I added the double hash marks (//) so you should be able to just copy and paste that entire section into XCode, making sure to at least replace "nameOfClassFileWithoutDotM" with the name of your class file / plugin file.
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
04/17/13 08:17 PM (12 years ago)
Code compiles without errors, however, how do I test that it is working? Should I use JSON Snippet Keeper? Jake
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/17/13 08:19 PM (12 years ago)
That would be one part of one way of doing it.
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
04/17/13 08:23 PM (12 years ago)
So how would this be formatted? {"itemNickname":"AlertTest", "itemId":"A56E3DBF421FB4ADF4F9663", "itemType":"BT_screen_blank", "button1ID":"A56E3DBF421FB4ADF4F7947", "button1Name":"YouTube", "button1Type":"BT_screen_customURL"} Jake
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/17/13 08:26 PM (12 years ago)
Looks like its properly formatted JSON. Whether it works for the custom plugin coding you've done is another question. I assume you have a file called "BT_screen_screen_blank.m"? (which isn't good practice in terms of naming conventions btw)
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
04/17/13 08:28 PM (12 years ago)
Oops, just a typo, yes the JSON name was wrong. Right now it is under the blank plugin, but I might call it jc_AlertView. Jake
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
04/17/13 08:34 PM (12 years ago)
So I tested it, but when I clock on "Button 1" it will not load to the screen specified in the JSON. Here is the new code (I think the problem starts on line 107): http://jworldhosting.com/Uploads/jc_UIAlert-b2.zip Jake
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/17/13 08:35 PM (12 years ago)
I'll have to look at it later - I'm on my phone and can't view the zip file contents. Sorry.
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
04/17/13 08:37 PM (12 years ago)
Any help is appreciated. Thank you. Jake
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/17/13 08:42 PM (12 years ago)
Will you be in St Louis by chance?
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
04/17/13 09:25 PM (12 years ago)
Unfortunately not. Jake
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.