Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 22    Views: 78

Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
06/02/14 05:18 AM (10 years ago)

Connecting Custom Plugin to Control Panel

I'm starting to get the hang of integrating custom made plugins into the control panel. I've been able to successfully create the required html, and get my options to show up and save in the custom plugins control panel area, and I think the only piece of the puzzle left is to use those "variables" stored in the json data in my code... the problem is, I'm getting an error when inserting the code. The goal is to simply take the text from a json field named "firstVariable" in the control panel and add it to a label in my project named myLabel. Here is what I'm using: NSString *tmpString = @""; tmpString= [BT_strings getJsonPropertyValue:self.myLabel.jsonVars nameOfProperty:@"firstVariable" defaultValue:@""]; I get the following xcode error: Property 'jsonVars' not found on object of type UILabel Where am I going wrong?
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/02/14 05:36 AM (10 years ago)
close it's self.screendata.jsonVars
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/02/14 05:57 AM (10 years ago)
As Kitssy said, make it be like this: tmpString= [BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"firstVariable" defaultValue:@""]; -- Niraj
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/02/14 05:57 AM (10 years ago)
Ahhhhh...... Sweet. I thought screendata was the name of the control in the example, haha. Thanks Kittsy, I'll give it a shot in a few minutes. :)
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/02/14 07:56 AM (10 years ago)
Hmmm... something still isn't right. See a screenshot of the error here: http://snag.gy/rP5lG.jpg
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/02/14 08:03 AM (10 years ago)
in the .h file have you changed the subclass from UIViewController to BT_viewController
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/02/14 08:16 AM (10 years ago)
aha, that was it :) Ok, so after doing that, my label changes to whatever I assign as the default value in the code, but will not display what I enter in that section of my control panel. Setting changes and saves fine in the CP, but isn't reflected in the app unless I hard code the default value to change it. Here's the code I'm using, and the label is linked up to the IBOutlet in interface builder.: NSString *tmpString1; tmpString1= [BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"firstSlider" defaultValue:@"Plot"]; firstSlider.text = tmpString1; If I change the value in my control panel that is linked to firstSlider to "plot2", it doesn't show, even after a fresh clean and refresh.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/02/14 08:35 AM (10 years ago)
a couple of things 1. it's not saving to json in the control panel, you can text by looking in the configdata fix check for typos. 2. this is from somebodies storyboard and is not the first viewcontroller. Then your going to have to code a few lines to blag what view you are on
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/02/14 08:38 AM (10 years ago)
Ah, ok, I didn't realize it had to be on the first viewcontroller. Yes, I'm using MrDavids storyboard code to push a couple of storyboards. Is there any documention somewhere that would show me how to reference the json from a secondary view?
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/02/14 08:42 AM (10 years ago)
Here's a screenshot if it helps. All related code is in the proper storyboards .h and .m files though, didn't add any of the json code to the main .h or .m... here's a screenshot that could probably explain it better than I... AN_Collector.m is the one that pushes the main storyboard, but all related CP json code is located in AN_CollectorViewController.h and .m. Where the code references "self" I would thing it would be looking in the right place... but maybe not? http://snag.gy/AcESG.jpg
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/02/14 08:43 AM (10 years ago)
no it's a trick I've found out it was easy in BT2.0 things changed in 3.0. It's a few lines of code, can't say off top of my head, not near my mac for a good few hours. Have an investigate yourself be as one with the code. Look at this [BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"firstVariable" defaultValue:@""]; What is it doing? Follow the white rabbit into wonderland. Might be another Kittsy tutorial coming on here
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/02/14 08:50 AM (10 years ago)
A tutorial would be fantastic... there is only one document that I know of that Smug did that even touches on hooking up control panel stuff, and I think all of us plugin developers would benefit from knowing how it all works. So, looking at the string of code, it's broken down like this... 1) Setup a string on the current view controller as a placeholder 2) Fetch the json data for the field named "firstVariable" 3) Take the string from firstVariable, and place it in the string placeholder on the current view 4) If nil, assign the default value specified In the screenshot here, http://snag.gy/AcESG.jpg , You'll see my app fires with AN_Collector and pushes AN_CollectorViewController. I would immediately think this was the issue, except I placed all CP JSON related code into AN_CollectorViewController.h and .m, and not AN_Collector.h & .m, so wouldn't "self" refer to the proper view in this case?
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
06/02/14 03:09 PM (10 years ago)
I would think you would create the string variable that holds json value in the main view controller class then pass the string to the class that sets the label text
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/02/14 03:13 PM (10 years ago)
Yeah, but I've got everything setup in the secondary view controller, since it handles everything except the pushstoryboard code. Literally the only thing in the main view controller of my plugin is just pushtostory and thats it. This one's got me stumped... can't seem to get it to work for the life of me. The rest of the plugin is basically done, only missing control panel hookups (and a few minor tweaks on the ipad compatibility) :(
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
06/02/14 03:20 PM (10 years ago)
create the string variable in the push story board class then pass it to the second view controller class thats sets the label.i think that would work but not sure havent tried it
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/03/14 08:23 AM (10 years ago)
Hmmm... still can't seem to get it to work :(
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/03/14 08:24 AM (10 years ago)
I'll get you the code lol
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/03/14 08:25 AM (10 years ago)
Thanks Kittsy. I usually don't stumble on things like this, lol. Would it help if I sent you the source?
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/03/14 08:26 AM (10 years ago)
I'll find a project with a storyboard to test, I'll use the hangman one
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/03/14 08:27 AM (10 years ago)
Cool, thanks :)
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/03/14 08:29 AM (10 years ago)
actually send me something with a storyboard the link has been cut from the control panel
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
06/03/14 08:36 AM (10 years ago)
Oh, yep, from when you suggested I lock down my BT server. PM sent with link to project. Thanks for the help!
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
06/03/14 07:41 PM (10 years ago)
Share when you got it solved! :-)
 

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.