Thanks,
I found this (http://codeendeavor.com/archives/535) nice wrapper for ASL and I
wanted to see how I could incorporate it in to my app. Since this is a
foundation tool I wanted to init it in my "myTestApp.m" main function, and be
able to call "[log info:@"Log Stuff"];" in any of my classes. I have never
really done this before. Should I just re-init it in each of my classes?
Thanks,
tom
On Nov 27, 2009, at 11:10 PM, Jens Alfke wrote:
>
> On Nov 26, 2009, at 9:18 AM, Tom Jones wrote:
>
>> I thought I could just create a Global variable but that does not work.
>
> Did you make it a pointer? You can't directly declare instances of any Cocoa
> classes, only pointers to them.
>
> So
> MyCocoaClass gFoo;
> is a syntax error, while
> MyCocoaClass *gFoo;
> works.
>
> Of course, you need some initialization code that allocates a new object and
> assigns it to foo. And you have to be sure that this code will run before
> anyone else tries to use gFoo. This can be problematic. Putting this code
> into your app delegate's awakeFromNib method is often sufficient, via
> something like this:
>
> - (void) awakeFromNib {
> gFoo = [[MyCocoaClass alloc] init];
> }
>
> Another way is to do the initialization in a class's +initialize method.
>
> —Jens
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]