Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / January 2005



Tip: Looking for answers? Try searching our database.

Why does this 4 line Cocoa Program not work ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lothar Scholz - 28 Jan 2005 10:46 GMT
int main(int a, char* av) {
  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
  NSRunAlertPanel(@"Title", @"My Message", @"Okay", nil,nil,NULL);
  [pool release];
}

It compiles and runs but NSRunAlertPanel does not show a popup.
Any ideas why ?

I need a cocoa wrapper to start an X11 application and if X11 is not
available the wrapper should simply popup a message box. Thats all.
Patrick Machielse - 28 Jan 2005 12:34 GMT
> int main(int a, char* av) {
>    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[quoted text clipped - 4 lines]
> It compiles and runs but NSRunAlertPanel does not show a popup.
> Any ideas why ?

I believe this function needs an instance of NSApplication to show your
panel.

> I need a cocoa wrapper to start an X11 application and if X11 is not
> available the wrapper should simply popup a message box. Thats all.

I think you can't use Cocoa. Look at this Carbon function:

StandardAlert

Displays a standard alert box.
OSErr  StandardAlert (
  AlertType  inAlertType,
  ConstStr255Param  inError,
  ConstStr255Param  inExplanation,
  const AlertStdAlertParamRec  * inAlertParam,
  SInt16  * outItemHit
);

patrick
Lothar Scholz - 28 Jan 2005 13:52 GMT
>> int main(int a, char* av) {
>>    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[quoted text clipped - 7 lines]
>I believe this function needs an instance of NSApplication to show your
>panel.

Yuups, thats it  

NSApplication* a = [[NSApplication alloc] init];

in front of the code and it works well.
Patrick Machielse - 28 Jan 2005 15:20 GMT
> >> int main(int a, char* av) {
> >>    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[quoted text clipped - 10 lines]
>
> in front of the code and it works well.

I overlooked that option ;-)

patrick
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.