applicationDidEnterBackground: Issue - xcode

I wrote an app that has about 3 different view controllers for each view in the tab bar. I called applicationDidEnterBackground: in each of the view controllers to save all the data in that specific view after the home button is tapped. This runs flawlessly on the iPad simulator, but for some reason, it crashed after trying to edit the data on the iPhone simulator. I thought this is probably an issue with putting the applicationDidEnterBackground: in the view controller, but if that was the issue, then wouldn't it crash on the iPad simulator as well?
I know that I should put applicationDidEnterBackground in the app delegate, but my method looks sort of like this:
- (void)applicationDidEnterBackground:(NSNotification *)notification {
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:firstField.text];
[array addObject:secondField.text];
[array writeToFile:[self dataFilePath] atomically:YES];
}
If I put this in the App Delegate, of course it doesn't recognize firstField or secondField because I did not declare it in header file or synthesize it or anything. If I were to declare everything in the App Delegate, then the outlets in my nib file will fail because each of the File's Owner's class is one of those specific view controllers.
Is the placement of applicationDidEnterBackground: not even my issue since it runs fine on the iPad simulator?
Also, it used to run fine on the iPhone simulator as well. I changed the Image View's background on all of the nibs, then this started happening. I rechecked all my outlets and actions and they match up fine.
EDIT: I fixed it. Turns out I had an extra field that I decided to add to the iPad's nib, but not the iPhone's. I though it would be fine, not the case though. That explains all the weirdness that was going on. I deleted the field in the iPad's nib and everything is A Okay. Phillipe, thank you so much for your help and offer to look it over for me, that is incredibly generous.

I fixed it. Turns out I had an extra field that I decided to add to the iPad's nib, but not the iPhone's. I though it would be fine, not the case though. That explains all the weirdness that was going on. I deleted the field in the iPad's nib and everything is A Okay. Phillipe, thank you so much for your help and offer to look it over for me, that is incredibly generous.

Related

Interface Builder is not working as expected after updating Xcode to 11.2.1 (11B53)

There are empty spaces on top of the View Controller. The UI was correct before updating to the latest Xcode Version. After updating to the latest version i got this behaviour. Some of the View Controller was correct updated butnot all. Check the Image to understand my problem (The View controller on the right side has an empty gray space.
If you compile it you see the same behaviour on the simulator (on all devices).
Looks like a second application in the background when you start the app.
I hope someone can help me.
Thanks!
you should config your ViewController when presenting like that:
yourViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self yourViewController animated:YES completion:NULL];
Try to set, parent ViewController's (Edit MemberVC, I assume) Top Bar property to None.

NSAttributed String shows in simulator but not on iPad device

My app works perfectly on the simulator, but not on my iPad. I have a UILabel (created programatically) that displays an NSAttributedString. The label itself appears, but the string won't display on the device (but works on simulator). I have confirmed through testing that the label will display a normal NSString, and I have also confirmed that if I create a UILabel with Interface Builder I can display attributed text in it.
The UILabel itself is a property of my view controller, declared with (strong, nonatomic).
I'm fairly new at this, so dumb mistakes are possible. Any idea what could be wrong?
Thanks.
I found the answer. It had nothing to do with UILabel or NSAttributedString. Turns out that the text files were not properly loading on my device, because the name of the file was capitalized in the bundle but not capitalized in my code. It worked on simulator because (it turns out) simulator does not care about file capitalization, but my device does. Once I got the text file to load, everything displayed as expected.

iPhone simulator not responding when using storyboards

I'm quite new to iOS Programming. I've done Objective-C for about a year, and now I want to start making apps for the iPhone. I think I'm missing out on something really simple, though. What I've done is this:
First I created a new Single View Application with TestApp as a product name. I enabled Use Storyboards, Use Automatic Reference Counting and Include Unit Tests. After creating the project, I dragged a UIButton onto the View in the storyboard file.
Note that I didn't write a single line of code. I launched my app in the iPhone Simulator and pressed the button, but it's not responding. I know I didn't assign an action to the press of the button, but the gradient of the button isn't changing, as I know it should. The User Interaction Enabled properties of both my view and my button were enabled.
Recently, I've created a few apps in Xcode that worked just fine, but I didn't use storyboards in those projects. Thus, I'm guessing there's something extra to do when using storyboards of which I'm just unaware. I'm using Xcode 4.5 and the iPhone 6.0 Simulator.
I wrote NSLog(#"View was loaded."); statement in the viewDidLoad method of my ViewController to make sure this view controller was actually loaded. (I know my button wouldn't show up if it was the wrong view controller, but I did this just to make sure.)
I also wrote a changeTitle: method in my ViewController to change the title of my button to New Title after it was pressed, just in case the button worked but its gradient just wouldn't respond to a tap. I linked this IBAction to my button, but it wasn't called.
In my ViewController, I created an IBOutlet of a UIButton which I connected to my button. In the viewDidLoad method of my ViewController, I changed the title of my button to New Title, this actually worked. The title of my button changed to this new title when launching my app in the iOS Simulator. The button itself still wasn't responding, though.
As a last try, I also wrote [button setEnabled:YES]; in my ViewController's viewDidLoad method, but this didn't help. My button still doesn't respond to any tap. What am I missing out on?
This is weird. I had an issue with my printer, so I restarted my computer. After this, this issue was suddenly solved as well (just like my printer issue). I'm not sure how this could have affected anything, but I'm glad it works again!
Ran into the same issue.
Apparently Content Reseting the Simulator worked for me
Very strange this..

Xcode Webview Output "null"

I'm developing an iPad app that supposed to output a website to another view, but when the second view loads, it comes up null. I'm using storyboard to link a button to push the web view controller and load the webpage into that view. The code works fine in the first view (indicated by NSLog), but NSURL never makes it to the second view (NSLog "Null").
Code in IBAction on first view:
self.sanctuaryWebViewController = [[SanctuaryWebViewController alloc]init];
self.sanctuaryWebViewController.URL = [NSURL URLWithString:#"http://www.website.org"];
Code in ViewDidLoad Second View Controller:
NSURLRequest *requestObject = [NSURLRequest requestWithURL:URL];
[webView loadRequest:requestObject];
I have done this in an Iphone app fine declaring a nav delegate to push the view, but not sure if using storyboard or splitview has anything to do with the problem. I spent hours searching for help and tried several different ways to code, but no go. I think I'm close, but not quite there. Using Xcode 4.4 and running on OS 10.8; IOS 5.1
Thanks for any suggestions
Can you show us more of the second view controller's code? I'm assuming you are using ARC? I assume you mean the result is coming up nil rather than NSNull (there is a difference)? Have you connected the webView in the second view controller to the UIWebView in the Storyboard/IB?
Good luck!
I was declaring UIWebview twice. "webview" and "_webview". I removed the instant variable declared in .h and kept the property. Made sure "_webview" was used. Also, Since I linked a segue to a button, I got rid of the IBAction method and replaced it with the prepareForSegue method, which calls the segue. Really had know idea what I was doing using storyboard. I knew about the segue methods, but did not realize they are not linked to the button like IBAction methods. They seem to be used in similar way as calling xib files, but calling segues.

Weird bugs and undefined behavior of Mac App

At the moment I am experiencing a really weird behavior of my Mac App.
On my Mac (and on all other testing Macs) everything works fine. The app simply works, no leaks,...
BUT on all the review Macs (Yes, on all) it fails: First the launch failed and now, after submitting it more times and trying to workaround the bug, it does not get initialized: Icons that should get loaded dynamically are not shown.
WHY?! Perhaps anyone has made experiences with such a problem because I cannot test it. I try to find the issue but it's nearly impossible.
[EDIT]
App Information:
My app should list all the currently running applications and display them in some way. It reads no files, only the NSUserDefaults to setup itself.
Structure:
appDidFinishedLaunching setups basic stuff like global hotkeys, loads the NSUserDefaults and finally forwards the message to the subclassed main window (<- There is the problem).
There it should load its interface which does not work on review Macs.
I was able to "override" or "fix" this by a little, dirty code snippet but it does not fix the main problem:
//AppDelegate.m
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self performSelector:#selector(didLaunch) withObject:nil afterDelay:0.5f];//<- THIS does the trick, so that the app launches and shows the static content of the NIB, but NO dynamic content is displayed: exactly the same nib state
//Register hotkeys, load NSUserDefaults,
[mainview launched];//<- Here is the problem
finishedLaunching=1;//global var
}
-(void)didLaunch//Launching works
{
if (finishedLaunching==0) {//=0 because of the review results
//Does all the stuff that [mainview launched]; is supposed to do: Display window and setup position
//Calling methods included in main view does not work (OR the window is not refreshed
//so the first start finally works, but the interface is EMPTY, only static content visible
}
}
Does the setup not happen because it is done in its subclassed window?
Why does it work on my Mac (and another Mac mini)?
Do you know why this happens, a way how to correct it or how to reproduce the bugs?
I really need your help and appreciate every tip!

Resources