The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. October 14, 2019, 07:19:49 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: objective-C hello world  (Read 2851 times)
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« on: January 25, 2009, 08:48:02 PM »

I'm playing around with coding for the iphone at the moment and I wanted to get a feeling for objective-C at a fairly low level.

I came up with this "hello world" example that others may find interesting.


Code:
// gday.m

#import <stdio.h>
#import <objc/Object.h>

@interface MyClass : Object {

    char* salutation;

}

- (MyClass*)init;
- (void)print;
@end


@implementation MyClass

- (MyClass*)init
{
   salutation = "G'day\n\0";
   return self;
}

- (void)print
{
  printf( "%s", salutation );
}

@end

int main(int argc, char *argv[])
{
  MyClass* gday = [[MyClass alloc] init]; // Allocate memory and initialise
  [gday print];
  [gday free]; // Free memory
  return 0;
}

// Compile with;
//      gcc gday.m -lobjc


Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: January 26, 2009, 07:13:27 AM »

Nice dood.

<3 the *
Logged

hai
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: January 26, 2009, 08:05:10 AM »

I'm psyched to see where you go with this TD ... I have yet to crack my books on XCode and iPhone development, looking forward to some spare time to do so. Love anything you want to post here.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #3 on: January 26, 2009, 08:23:28 AM »

spare time...  ROFLMAO
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: January 26, 2009, 08:47:39 AM »

yeah I know.  Undecided
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #5 on: January 26, 2009, 04:14:26 PM »

@VS I owe you an apology dude. I never could get that "product" for you, the download wouldn't complete and I couldn't find it anywhere else.

Sorry,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!