Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old February 18th, 2008, 02:05 PM
mck9235 mck9235 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 34 mck9235 User rank is Lance Corporal (50 - 100 Reputation Level)mck9235 User rank is Lance Corporal (50 - 100 Reputation Level)mck9235 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 7 h 2 m 23 sec
Reputation Power: 4
Objective C/Cocoa?

Hey all, I'm trying to learn Cocoa/Objective-C. I've been reading along with a guide from Apple, and I came across this sample code.
Code:
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    NSArray *args = [[NSProcessInfo processInfo] arguments];

    NSCountedSet *cset = [[NSCountedSet alloc] initWithArray:args];

    NSArray *sorted_args = [[cset allObjects]

        sortedArrayUsingSelector:@selector(compare:)];

    NSEnumerator *enm = [sorted_args objectEnumerator];

    id word;

    while (word = [enm nextObject]) {

        printf("%s\n", [word UTF8String]);

    }

    [cset release];

    [pool release];

    return 0;

}

The problem is I just don't know how to run it? I've tried using XCode, but it doesn't let me build/run a single file, only a project, but that's not what I'm doing. I just want to run this single class to see how it works!

Any help is appreciated (as well as other resources for learning Cocoa)

Thanks

Reply With Quote
  #2  
Old June 1st, 2008, 10:55 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Hi,

This isn't a class. The main function is the entry point for the program. When it's run execution will start here. Anyway, You could do this from the Terminal but you need to link against at least one system library. It'd be simpler to create a new Xcode project and replace the main function provided with this one.

NSCountedSet is a Bag in the mathematical sense of the word, so I'm guessing that this code prints out occurrences of a word.

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Objective C/Cocoa?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway