Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Getting Started with iPhone Development?

Getting Started with iPhone Development?
Thread Tools
jamil5454
Mac Elite
Join Date: Oct 2004
Location: Downtown Austin, TX
Status: Offline
Reply With Quote
Mar 13, 2008, 06:41 PM
 
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)applicationDidFinishLaunchingUIApplication *)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.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Mar 13, 2008, 06:51 PM
 
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'."
     
jamil5454  (op)
Mac Elite
Join Date: Oct 2004
Location: Downtown Austin, TX
Status: Offline
Reply With Quote
Mar 13, 2008, 07:30 PM
 
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).
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Mar 13, 2008, 08:01 PM
 
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'."
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 09:42 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,