Feather
I hate code!
Profile
Posts: 22
Reg: Oct 22, 2013
San Diego
7,720
10/22/13 10:00 PM (12 years ago)

Need some help with an If statement :(

First off, hi! I'm trying to change the way the icons look on a certain screen. MrVanBeveren (MrDavid, my soon to be hubby) gave me this code to tinker with, but it's not working! In WB_cell_menuList.m, I replaced line 76 ([cellImageView setContentMode:UIViewContentModeScaleAspectFill];) with the below code: NSString *thisItemNickname = [BT_strings getJsonPropertyValue:screenData.jsonVars nameOfProperty:@"itemNickname" defaultValue:@""]; if ([thisItemNickname isEqualToString:@"Videos"]) { [cellImageView setContentMode:UIViewContentModeScaleAspectFill]; } else { [cellImageView setContentMode:UIViewContentModeCenter]; } The error I get is: "use of undeclared identifier "screenData"". Does anyone have any idea why this is occuring? Thank you for your help! Samantha
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
10/22/13 10:05 PM (12 years ago)
@Kittsy was the awesome guy who originally gave me this code, it works perfectly in the button menu. We tried synthesizing it and declaring it in the .h files, which got rid of the error, but the code was not functioning at all. We must have not actually fixed it, rather only made xcode happy. p.s. nice first post ;-) David https://buzztouchmods.com/market
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/22/13 10:23 PM (12 years ago)
I know 'why' it's occuring... haven't thought about what can be done about it. First off, welcome! Any fiancé of Mr. David is a friend of mine! The thing is, the information in the 'screenData' isn't available in the WB_cell_menulist module, so when you try to get the information, it's going to cough. So what you'll need to do is: 1) Create a new Variable in your WB_cell_menulist.h/m file, name it "myNewVariable" or whatever you're comfortable with. 2) Set the value of the new variable in your WB_screen_menuImage.m file, right after line 398 When you set the WB_cell_menuList as '*cell' 3) go back and do your 'if' statement with your new variable. A) so in your WB_cell_menuList.h file add: @property (nonatomic, assign) NSString *myNewVariable; B) in your WB_cell_menuList.m file, 'synthesize' the variable with the others (add it with them) synthesize myNewVariable; C) in your WB_screen_menuImage file (add this around line 399 or so) WB_cell_menuList.myNewVariable = [BT_strings getJsonPropertyValue:screenData.jsonVars nameOfProperty:@"itemNickname" defaultValue:@""]; D) in your WB_cell_menuList.m file do this instead: if ([myNewVariable isEqual: @"videos"]) { [cellImageView setContentMode:UIViewContentModeScaleAspectFill]; } else { [cellImageView setContentMode:UIViewContentModeCenter]; } or something close to that; it may take a little playing around with. Hope this helps! Cheers! -- Smug
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/22/13 10:28 PM (12 years ago)
@David and @Sam, The thing is, you have to provide a value for the variable 'in a place where both the screenData is recognized, and the WB_cell_menuList is recognized'. This happens in the WB_screen_menuImage.m file around line 399 or so... Right after you've declared '*cell' as a WB_cell_menuList object. Then you can set the variable value from the accessible screenData Json information... Then just go back to your WB_cell_menuList.m file and finish up the same way, just using your new variable instead of trying to get the json in an area where it's not available. Does that make sense? Cheers! -- Smug
 
Feather
I hate code!
Profile
Posts: 22
Reg: Oct 22, 2013
San Diego
7,720
like
10/22/13 11:46 PM (12 years ago)
Thanks so much for the quick response. I have to be honest, I probably won't have the time tonight to try it out. I'll do it early tomorrow though and probably ask some questions. It seems to make sense but when I go to actually do it, it could be a different story. I'll let you know. Thank you! :] MrsVanBeveren
 
Feather
I hate code!
Profile
Posts: 22
Reg: Oct 22, 2013
San Diego
7,720
like
10/23/13 01:51 PM (12 years ago)
Thank you for the help! I think I've almost got it working, appreciate everything! MrsVanBeveren
 

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.