Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
11/27/14 08:57 PM (9 years ago)

Strange Xcode Brainfart

I'm working on an app that is using non-BT screens, and rather loading XIB's individually, but still using the BT framework. I just started with a BT_screen_blank, then added my own xib's, .h's, and .m's. The strange behavior I'm experiencing is that when loading an XIB, it loads fine, but all code seems to have to go into the BT_screen_blank.m file... like its locked down to that file for some reason. If I put for instance my IBAction code in my whatever.h and whatever.m files, the connection inspector sees them, but they won't actually execute unless I put a copy of the IBAction code in the first screens BT_screen_blank.m file as well. I checked all of my file owner classes, and made sure they were all connected to the views. I also made sure that all outlet connections were correct and hooked up, which they are, because Xcode sees the outlets and lets me connect them. But if I don't copy the IBAction code into the BT_screen_blank.m file as well, they don't do anything. Here is an example of my structure for one set of files: Garden.h Garden.m Garden.xib Garden.xib has "Garden" set as the file owners class, and the view for the XIB has been connected to the file owner. However, any code that I put in Garden.m must also be copied into BT_screen_blank in order for it to work, otherwise I get the following error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BT_screen_blank GoToGarden1]: unrecognized selector sent to instance 0x7c09c2d0' Which you can see that it's looking for the code in BT_screen_blank.m Is there something that is making BT_screen_blank take control of all the code in my other files? Sorry if it's a noob question, but I'm learning more and more about xcode each day. I guessed that the file owner would be what makes it look to a particular file for the matching code, but I guess there must be something else. Any ideas? Chris1, Niraj or Kittsy... you guys are probably face palming yourselves right now after reading this, lol. I know it's got to be something simple that I'm missing.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/27/14 09:55 PM (9 years ago)
I'll tell you this, without looking at your code, it's not looking for code in your class, it's having problems communicating between both in the first place. Send me the app and I bet I can fix this up for you in no time. I spent most of the past several months working with custom written classes through the BT framework with no issues at all, BT works splendid this way and was designed for this infact. FYI: GoToGarden1 is the method that's called in your BT_screen_blank class, so naturally, unless the GoToGarden1 method is in that class file (which it wouldn't be, it would be in your Garden class), it's not going to be able to call it. If you need to call that method for some reason inside of your BT_screen_blank class, and you don't want that method moved from your Garden class, you're going to have to make class methods. Don't forget to reference them in your .h file, this way you can access that method anywhere ;-) You're probably messing with instance methods right now. You would call your theoretical class method this way: [Garden GoToGarden1]; (Garden being the class file, GoToGarden1 being the method you want to invoke in that class) - this could run that code from your BT_screen_blank class - does this help? Also, just create a new class file, don't use the BT_screen_blank, or at least rename to something more relevant. You have my email if you want to send it over, I'll explain what's wrong once I see what your doing. Edit: noticed you noticed that it's looking for code in your main class, your not linking them correctly then through interface builder - there's absolutely no reason it needs to have that code there. I'll be able to tell when I see the project what's wrong, but for-sure something iffy. :-) David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
11/27/14 10:12 PM (9 years ago)
Awesome, thanks! I just PM'd you a link to download it... 33mb with the fb SDK, so figured it better than email. :)
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/27/14 10:37 PM (9 years ago)
Whoa crazy - I see what you mean! You're trying to call a method from a IBAction in your WF_Gardens class, however, when pressed, it acts as if it's trying to call the method from BT_screen_blank instead of WF_Gardens - is this correct? David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/27/14 10:49 PM (9 years ago)
Headed to bed (almost one AM here, but let's try this...) Let's force the damn thing to launch your method from WF_Gardens instead of it auto looking at BT_screen_blank... Do this... 1. Edit your GoToGarden1 IBaction in WF_Gardens to do this... [WF_Gardens GoToGarden1Real]; // call your method and reference your own class 2. Now your GoToGarden1 old method, copy it and rename it (that loads your next nib) should become GoToGarden1Real.. then change it from a instance method to a class method like this.. +(void)GoToGarden1Real{ //load nib code here } So what we're doing here is we are telling your code to force check for that method in the class you want the method to be in, which theoretically should work. If it's not working I'll check it out tomorrow evening for you, had a rough Thanksgiving and need my sleep... LOL! Cheers. David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
11/28/14 10:38 AM (9 years ago)
Yep, that's exactly the problem. I've never seen an Xcode project do that before. I've even tried redownloading the blank project, still the same thing. I tried as you suggested, still get the same error... *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BT_screen_blank GoToGarden1]: unrecognized selector sent to instance 0x7a7cd780' It's still trying to pull the info from the BT_screen_blank.m file for some reason, even after editing the GoToGarden1 and creating the new +(void)GoToGarden1Real. Really strange.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/28/14 10:40 AM (9 years ago)
You're kidding me? That code forces it to grab it from your Garden class. Let me keep messing around with it. David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
11/28/14 10:42 AM (9 years ago)
Yeah, it's almost like it's trying to pull from the BT_screen_blank file before it even reads the garden class.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/28/14 10:44 AM (9 years ago)
Try running the thread like this... [[[NSBundle mainBundle] loadNibNamed:@"WF_Garden1" owner:self options:nil]objectAtIndex:0]; David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/28/14 11:02 AM (9 years ago)
Follow ray's guide here with me: http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1 I have a hunch that the memory in BT_screen_blank isn't getting deallocated, or that your app doesn't detect you leaving your class, through I have no idea why - retain in your properties? Shouldnt be affecting anything... it's getting frustrating now, LOL. Have you thought about hardcoding the button and pushing from that? I'm sure it has something to do with your XIB's, you could avoid just the button part by hardcoding a UIButton. CGRect buttonFrame = CGRectMake(10, 100, 200, 30 ); UIButton *goToGardenButton = [[UIButton alloc] initWithFrame:buttonFrame]; [goToGardenButton setTitle: @"GO TO GARDEN" forState: UIControlStateNormal]; [goToGardenButton addTarget:self action:@selector(GoToGarden1:) forControlEvents:UIControlEventTouchUpInside]; [goToGardenButton setTitleColor: [UIColor redColor] forState: UIControlStateNormal]; [view addSubview:goToGardenButton]; Bah. David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
11/28/14 11:02 AM (9 years ago)
Nope, same thing :( Here is what the section of code now looks like in WF_Gardens.m +(void)GoToGarden1Real{ [[[NSBundle mainBundle] loadNibNamed:@"WF_Garden1" owner:self options:nil]objectAtIndex:0]; } -(IBAction)GoToGarden1{ [WF_Gardens GoToGarden1Real]; // call your method and reference your own class } And of course the button on the XIB is connected to the GoToGarden1 outlet.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/28/14 11:03 AM (9 years ago)
Check out my last response, we posted at the same time LOL! David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
11/28/14 11:05 AM (9 years ago)
Hmmm... was trying to avoid hard coding the Ui elements... theres going to be a ton of them in later screens, and even IBActions on Garden1.m behave the same way, looking for code on the BT_screen_blank.m file. For example, I tried to run code on Garden1.m that determined if a UIIamage was hidden or not, then run code based on the result... it still looked for the code in BT_screen_blank.m... and that was in one screen deeper than the one we are working on now.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/28/14 11:09 AM (9 years ago)
Gotcha - avoiding the issue now might cause more issues in the future. Now that I think of it, I remember BT used to have issues with the hierarchy when going from a BT class to a non-BT class back in the day, though that shouldn't be an issue anymore. Do you have my Storyboard plugin? Or Chris's XIB plugin? We should mess with those. David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
11/28/14 11:13 AM (9 years ago)
Yeah, I have the storyboard plugin. I THINK I have Chris's XIB plugin, but I'll have to double check. I have his ultimate screen creator, but haven't played with it much yet, and based on what I'm working with, I don't think that one would help much... lots of custom stuff going on in the upcoming XIB's, and I'm designing in landscape. Another option... I could do this app without BT at all, but I haven't quite got my head around the default project files and using appdelegate, viewcontroller, and replacing the default main.storyboard with an XIB instead. Been spoiled with BT too much ;) Plus, having all of the BT code in there will make for easier additions of features later on, and allow me to use my google maps api in my BT control panel to see where my users are coming from.
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
11/28/14 01:17 PM (9 years ago)
Just recreated the entire project on my BT control panel, using Chris1s XIB button menu instead... Didn't copy anything, created all new XIB's, .H, and .M files by hand... same issue. Now it's looking in JM_Xib_button_menu.m code for all classes. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[JM_Xib_button_menu GoToGarden1]: unrecognized selector sent to instance 0x78ff5e90' PM'ing you a link to the new project, since it's much cleaner. Maybe you can find something that I can't. Really weird that it's happening on the newly created project as well.
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
11/29/14 11:16 AM (9 years ago)
I have it narrowed down to something to do with the method I'm using to call load the XIB, or the fact that I'm loading a new XIB but it's not releasing the previous view controller first. Not sure where to go from there though to remedy the situation. Is there a way to manually release the old view controller just as I'm calling the new one?
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
11/29/14 11:20 AM (9 years ago)
Hi Angry, Right, that's what I thought - it's not releasing the previous view. You could try manually releasing, but the problem is you're using ARC - it will most likely yell at you. I'm still looking... David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 

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.