|
|
Getting Started with iPhone Development?
|
|
|
|
Mac Elite
Join Date: Oct 2004
Location: Downtown Austin, TX
Status:
Offline
|
|
I can't seem to get started with iPhone development. Even the simplest tasks seem extremely complicated. For instance, on my two hour plane flight I decided to try and get a HelloWorld app running in the Aspen simulator using the built-in iphone sdk reference manual in XCode. Well, after lots of frustration I still wasn't getting anywhere.
Then, I looked at this which seemed to help, but I'm getting errors with my NSString.
I created a Cocoa Touch app and without changing anything else, here's what my testAppDelegate.m looks like:
Originally Posted by code
#import "testAppDelegate.h"
#import "MyView.h"
@implementation testAppDelegate
@synthesize window;
@synthesize contentView;
- (void)applicationDidFinishLaunching UIApplication *)application {
// Create window
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Set up content view
self.contentView = [[[MyView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
[window addSubview:contentView];
NSString * myText = @"Hello World!";
[myText drawAtPoint:CGPointMake(100.0,100.0) withFont:[UIFont systemFontSize]];
// Show window
[window makeKeyAndVisible];
}
- (void)dealloc {
[contentView release];
[window release];
[super dealloc];
}
@end
I STILL can't seem to get it to work... that code is directly from Apple's documentation and it's giving a compile error with the withFont property. I'm also new to Cocoa/Objective-C but I'm the kind of person that learns by doing, and if this is any sign, it's going to take a long time to learn Cocoa Touch. I've spent a few days trying various things but I just can't seem to get "Hello World!" to show up on the screen.
Help is much appreciated.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
The method wants a font (i.e., a UIFont), while you're passing in a font size (i.e., a CGFloat).
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 2004
Location: Downtown Austin, TX
Status:
Offline
|
|
I just changed the line to:
[myText drawAtPoint:CGPointMake(100.0,100.0) withFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
Now, the app runs in Aspen but it doesn't display anything. I'm guessing that somehow the string isn't getting drawn in the window that's visible (or something along those lines).
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Looking at the rest of your code, I see you're not drawing in any view. You should do all drawing inside a UIView subclass's -drawRect: method.
By the way, I understand about learning by doing, because getting dirty and trying stuff really can be the best way to learn, but I think it would be useful to you to read the introductory docs (it looks like you may have read some already since you're doing memory management correctly) and work through a few tutorials. Cocoa is a fairly big framework with a lot of conventions like "you have to draw within a -lockFocus pair, but this is normally called for you," and it will be a lot easier to handle if your head is in the right place.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|