Simple issue with basic iPhone application.
apple Verified ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I have a simple app that I am trying to get functioning properly. The app will launch and run in the simulator and quit before I can see anything. I have made my Label Connection between the File Owner and the label by selecting the label on my background, selecting Connections Inspector in the Tools menu and then dragging from the plus sign under 'New Referencing Outlet' to the 'File Owner'. Once done I selected my label and this is the result. any idea how to fix this so the app will run now?
15 replies
Sign in or join Beachball Help to reply.
- 0
K T ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Do you know how to set break points as a debugging procedure?
iPhone Dev Center: Xcode Debugging Guide: Managing Program Execution
- 0
kneedragger101 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Yes, I do but that's not the issue. The app will run, open real quick and close in the iPhone simulator. There are no errors.
- 0
kneedragger101 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I set a breakpoint and this is what I got: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MinutesToMidnightViewController" nib but the view outlet was not set.'
- 0
K T ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Typically, this message (w/black screen) occurs when the viewcontroller is not hooked up to the view.
Have you done that correctly/completely?
Did you save any/all changes in Interface Builder?
Build & Go in Xcode doesn't save changes in both Xcode & IB...
- 0
kneedragger101 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I thought I did that. When I first create the app I put a label on a screen, then I set its attributes, write the class files, merge them and save. When I go in xCode and build+run I see the label in the iPhone simulator as expected. When I go back into xCode to add my code to manipulate the UI is when I get this error.
I need some help. How do you fix this error please?
- 0
K T ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
+>When I go back into xCode to add my code to manipulate the UI+
You might need to post that code here for someone to analyze, etc. Makes it a guess otherwise (excpet for Ray, who usually is one step ahead) 🙂
Know how to format code in a post?
- 0
kneedragger101 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
This is all the code.... I was following the tutorial found here:
http://appsamuck.com/day1.htmlThanks, I'm a newbie top the Mac world.
// MinutesToMidnightViewController.m
// MinutesToMidnight#import "MinutesToMidnightViewController.h"
@implementation MinutesToMidnightViewController
-(void)viewDidLoad {
[countdownLabel setFont:[UIFont fontWithName:@"DS-Digital" size:64.0]];
countdownLabel.text = @"I0A0IN6";
[super viewDidLoad];
}- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceO rientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];// Release any cached data, images, etc that aren't in use.
}- (void)dealloc {
[super dealloc];
}-(void)updateLabel {
NSDate* now = [NSDate date];int hour = 23 - (int)[[now dateWithCalendarFormat:nil timeZone:nil] hourOfDay];
int min = 59 - (int)[[now dateWithCalendarFormat:nil timeZone:nil] minuteOfHour];
int sec = 59 - (int)[[now dateWithCalendarFormat:nil timeZone:nil] secondOfMinute];
countdownLabel.text = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, min,sec];}
@end
------
// MinutesToMidnightViewController.h
#import <UIKit/UIKit.h>
@interface MinutesToMidnightViewController : UIViewController {
IBOutlet UILabel *countdownLabel;
}-(void)updateLabel;
@end
-----
// MinutesToMidnightAppDelegate.m
#import "MinutesToMidnightAppDelegate.h"
#import "MinutesToMidnightViewController.h"@implementation MinutesToMidnightAppDelegate
@synthesize window;
@synthesize viewController;- (void)applicationDidFinishLaunching:(UIApplication *)application {
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}- (void)onTimer {
[viewController updateLabel];
}- (void)applicationWillTerminate:(UIApplication *)application {
[timer invalidate];
}- (void)dealloc {
[timer release];
[viewController release];
[window release];
[super dealloc];
}@end
-----
// MinutesToMidnightAppDelegate.h
#import <UIKit/UIKit.h>
@class MinutesToMidnightViewController;
@interface MinutesToMidnightAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;
IBOutlet MinutesToMidnightViewController *viewController;
NSTimer *timer;
}
-(void)onTimer;
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) MinutesToMidnightViewController *viewController;@end
- 0
K T ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
And which is _just your part_, that you added ("...my code to manipulate the UI") that broke things?
- 0
Charles Minow ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
kneedragger101 wrote:
This is all the code.... I was following the tutorial found here:
http://appsamuck.com/day1.html
[countdownLabel setFont:[UIFont fontWithName:@"DS-Digital" size:64.0]];For what it's worth, I downloaded the Xcode project off that page and compiled it. They have a different font name in their code. If I put in your code, I also get an exception, though it specifically mentions not being able to find the font.
One thing you could do is download the Xcode project and open it up and look and see if you can figure out the difference between your project and theirs. Alternatively, if you can find a place to post your Xcode project so people can download it, that can be helpful, too.
Finally, when you post code, put it between {code} tags. In other words, post it like this:
{
code}
some code
some other code
some more code{
code}That makes it easier to read since the forum software leaves some of the special characters alone.
charlie
- 0
kneedragger101 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Can you try a different font?
- 0
kneedragger101 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I tried a different font, and all I get is a blank screen on my iPhone simulator. No errors, it runs but I get nothing. I did install that font on my machine. Any ideas? My code is the same code that was on the page I provided for the tutorial.
- 0
kneedragger101 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Here is the error I am getting when I use a breakpoint.
The Debugger has exited due to signal 15 (SIGTERM).The Debugger has exited due to signal 15 (SIGTERM).
[Session started at 2010-01-29 13:04:25 -0500.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18 20:40:51 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 22612.
Pending breakpoint 1 - ""CountdownViewController.m":16" resolved
2010-01-29 13:04:27.841 Countdown[22612:207]
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "CountdownViewController" nib but the view outlet was not set.'
2010-01-29 13:04:27.843 Countdown[22612:207] Stack: (
29258843,
2507441417,
29342779,
29342618,
3215930,
3209275,
3208993,
9075,
2692639,
2730506,
2718600,
2701011,
2728117,
37355217,
29043584,
29039688,
2694761,
2732035,
8900,
8754
)
(gdb) - 0
kneedragger101 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Ok, good news! I clicked on File's Owner, opened the Connection Inspector, added a View Controller to my Documents window and then with the File's Owner still selected dragged my view to my View Controller. I got the idea here >
http://bill.dudney.net/roller/objc/entry/demystifyingview_controllers_andviewsNow I was showing an error in the debugger because of the font. I changed the font to Helvetica and it worked as expected! I installed the font on my Mac and I can see it int the Font window inside Interface Builder but I am getting this error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: font != nil'
Any idea how to solve this?
- 0
Charles Minow ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
kneedragger101 wrote:
Now I was showing an error in the debugger because of the font. I changed the font to Helvetica and it worked as expected! I installed the font on my Mac and I can see it int the Font window inside Interface Builder but I am getting this error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: font != nil'Any idea how to solve this?
A Google search for
iphone app custom font shows that you've now moved out of "simple" land and into more treacherous waters.There's a post at
Stack Overflow. Another on a
blog. And
another blog post.Also, keep in mind that if you want to distribute the app you're making, you'll need to make sure you have the legal right to distribute the font. If it's a custom font you created yourself, then that wouldn't be a problem.
charlie
- 0
kneedragger101 ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
So I have seen this code over at Stack Overflow to add a custom font to my application. I'm not concerned with using this for distribution I just want to know how to do it...
BOOL GSFontAddFromFile(const char * path);
NSUInteger loadFonts()
{
NSUInteger newFontCount = 0;
for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil])
newFontCount += GSFontAddFromFile([fontFile UTF8String]);
return newFontCount;
}Once fonts are loaded, they can be used just like the Apple-provided fonts:
NSLog(@"Available Font Families: %@", [UIFont familyNames]);
[label setFont:[UIFont fontWithName:@"Consolas" size:20.0f]];