|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Objective C/Cocoa? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|