• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Learning to program Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Learning to program Cocoa


  • Subject: Re: Learning to program Cocoa
  • From: Ondra Cada <email@hidden>
  • Date: Tue, 28 Aug 2001 17:33:53 +0200

David,

>>>>>> David Trevas (DT) wrote at Tue, 28 Aug 2001 09:46:20 -0500:
DT> The good news about learning C is that you can use your eventual tool
DT> for writing Cocoa programs, Project Builder, to do your C exercises.
DT> The key is when you open up a new project and the dialog about the types
DT> of project you want comes up, go all the way to the bottom and under
DT> Tools, choose Standard Tool. Couldn't they just have called it a
DT> "Standard C Tool" and helped many people like me avoid the confusion? I
DT> hope you learn from my struggle!

There is no need. Feel free to use a Cocoa tool instead; there is *NO* C
thing you would not to be able to use in ObjC. The superfluous
NSAutoreleasePool thing generated for you is harmless and you can freely
ignore it. Like:

#import <Foundation/Foundation.h>

int main (int argc, const char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

// insert your code here

// A VERY PLAIN C HELLOWORLD WITH SOME ARGC/ARGV USAGE
int i;
printf("Hello, world there!\n\n");
printf("We were called as \"%s\"\n",argv[0]);
printf("with these arguments:\n");
for (i=1;i<argc;i++) printf("%d -> \"%s\"\n",i,argv[i]);

[pool release];
exit(0); // _E_nsure the process exit status is 0
return 0; // ...and make main fit the ANSI spec.
}


The advantage of this approach is that you will be able to add ObjC/Cocoa
tidbits to your test C programs anytime. With Standard Tool, it would need
some more work -- not difficult, but annoying for a total newbie.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


  • Follow-Ups:
    • Re: Learning to program Cocoa
      • From: Finlay Dobbie <email@hidden>
References: 
 >Re: Learning to program Cocoa (From: David Trevas <email@hidden>)

  • Prev by Date: Re: C++
  • Next by Date: Save NSView content as planar raw bitmap
  • Previous by thread: Re: Learning to program Cocoa
  • Next by thread: Re: Learning to program Cocoa
  • Index(es):
    • Date
    • Thread