Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xode 4.5 Hello World example doesn't work

Tags:

macos

xcode4.5

I am pretty much an XCode beginner, and I therefore tried the, "Hello World" example given in the XCode documentation: Quick Start Guide: Tutorial: Using Xcode to Write “Hello, World!” for OS X.

I am using XCode 4.5.1 from whose documentation I took this example using OS 10.8.2. I followed the instructions; the example didn't work. It produced the window but not the "hello world" printing. The relevant code is:

- (void)drawRect:(NSRect)dirtyRect
{
    // Drawing code here.
    NSString *hello = @"Hello, World!";
    NSPoint point =NSMakePoint(15, 75);

    NSMutableDictionary *font_attributes = [[NSMutableDictionary alloc] init];
    NSFont *font = [NSFont fontWithName:@"Futura-MediumItalic" size:42];
    [font_attributes setObject:font forKey:NSFontAttributeName];

    [hello drawAtPoint:point withAttributes:font_attributes];

    [font_attributes release];
}

There are two notable things. The last line of this code gives an error:

release is unavailable: not available in automatic reference counting mode

So I commented this line out and ran the program. The window appeared, but no "Hello World". A long message appeared in the All Output, part of which read:

"/Users/me/Library/ScriptingAdditions/YouHelper.osax/Contents/MacOS/YouHelper: no matching architecture in universal wrapper
Hello: OpenScripting.framework - scripting addition "/Users/me/Library/ScriptingAdditions/YouHelper.osax" declares no loadable handlers."

Am I doing something dumb, or am I using the wrong example?

like image 685
user1726245 Avatar asked Mar 25 '26 20:03

user1726245


1 Answers

You have to remove [font_attributes release]; at the end of your code. release, retain, alloc and dealloc are not available in ARC(Automatic Reference Counting). This is what the error says. And for the second error you should remove anything that is referring to AppleScript and similar scripting addons for the app.

like image 192
user1473223 Avatar answered Apr 02 '26 18:04

user1473223



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!