Writing an ObcJ function/calling it from C++
Well, close: you need to compile it as ObjectiveC++. (with the .mm extension, as OSC said)
Ack, I seem to be receiving many suggestions at once.
I can either use the temporary solution, which sounds easy and will be quick or I can come up with a more organized permanent solution right now. I'd rather do the latter, because this is code I plan to use later to produce other standard error messages.
Deprecation is what I want to avoid in the this case. Cocoa is preferable because it will work a lot better in the future, I hope.
When I started this thread I hoped there would be a very simple function for displaying dialogs like the windows MessageBox() command (gotta love how easy that is
) but for Mac OS X. Something that didn't require use of Cocoa classes or instances (or simply: something that didn't require a whole lot of extra learning for a simple dialog). I'll have to admit that I approached this with a feeling of "It's just a message box darnit!". But if this is unavoidable then I feel I'd be better off learning some Cocoa anyway and coming back to this later once I've got a better understanding of this language.
And Cookie, I'm not sure I'd call my attitude towards compiler errors 'Cavalier'. Admittedly I may not understand all of them as well as many others here, but they are not something I regard offhandedly.
I can either use the temporary solution, which sounds easy and will be quick or I can come up with a more organized permanent solution right now. I'd rather do the latter, because this is code I plan to use later to produce other standard error messages.
Quote:Also, don't use StandardAlert; it's ancient, nasty, and deprecated. There are better ways of doing it (just say whether you want Cocoa or Carbon code).
Deprecation is what I want to avoid in the this case. Cocoa is preferable because it will work a lot better in the future, I hope.
When I started this thread I hoped there would be a very simple function for displaying dialogs like the windows MessageBox() command (gotta love how easy that is
) but for Mac OS X. Something that didn't require use of Cocoa classes or instances (or simply: something that didn't require a whole lot of extra learning for a simple dialog). I'll have to admit that I approached this with a feeling of "It's just a message box darnit!". But if this is unavoidable then I feel I'd be better off learning some Cocoa anyway and coming back to this later once I've got a better understanding of this language.And Cookie, I'm not sure I'd call my attitude towards compiler errors 'Cavalier'. Admittedly I may not understand all of them as well as many others here, but they are not something I regard offhandedly.
Code:
+ (NSAlert *)alertWithMessageText:(NSString *)messageTitle defaultButton:(NSString *)defaultButtonTitle alternateButton:(NSString *)alternateButtonTitle otherButton:(NSString *)otherButtonTitle informativeTextWithFormat:(NSString *)informativeTextWithFormat, ...That is,
Code:
[NSAlert alertWithMessageText:@"Message" defaultButton:@"OK" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"You made %d programming errors", 17];If you have C strings, +[NSString stringWithUTF8String:] is your friend.
If you're doing this outside the Cocoa event loop, you will need
Code:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// ... run your alert here
[pool release];To avoid the "you're leaking" warnings you quoted earlier.
Well, that seems like a quick, clean and safe way to do this. 
Thank you very much OSC.

Thank you very much OSC.
If I drop in OSC's code it compiles, but never displays a message.
You know, I should have just stuck with OpenGL rendered error messages. It would've caused much less trouble.
Thanks for your help, but I've asked for too much assistance for this simple problem already. I shall find another solution.
You know, I should have just stuck with OpenGL rendered error messages. It would've caused much less trouble.
Thanks for your help, but I've asked for too much assistance for this simple problem already. I shall find another solution.
You need to call -[NSAlert runModal] on your alert instance to display it...
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Writing libraries vs writing apps. | Najdorf | 8 | 4,470 |
Nov 13, 2008 02:32 PM Last Post: backslash |
|
| Better way of calling a function in another class? | brush | 5 | 3,908 |
Jun 12, 2008 11:23 PM Last Post: AnotherJake |
|
| Problem drawing pictures after calling RunApplicationEventLoop | petr6534 | 5 | 4,183 |
Feb 8, 2005 06:58 PM Last Post: petr6534 |
|

