[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
stupide question
From: |
Pascal Bourguignon |
Subject: |
stupide question |
Date: |
Sat, 23 Aug 2003 12:09:22 +0200 |
Yes, it is.
reuss writes:
> have somebody experiences with gnustep+ncurses?
> if any, is it possible to treat ncurses *ptr-s as NSString-s?
> thanks
Objective-C is a strict superset of C. That means that in Objective-C
programs, functions and methods, you can use plain old C functions,
and in Objective-C types and classes, you can use plain old C types
and structures.
So, for one thing, you can perfectly use ncurses in an Objective-C
program that uses GNUstep. On the other hand, ncurses is for driving
textual terminals, not bitmap displays, but you can have either a
terminal emulation inside a GNUstep window, or have a "multiheaded"
application that has both windows and terminal interfaces (or even
just a CLI tool without a GUI).
Now a second point is how do you manipulate *ptr objects. I don't
know ncurses, so I'll assume that'a a plain old C string type.
Normally, you'd use the standard C library functions to manipulate it
(strcpy, strchr, sprintf, etc...). If you miss some function found in
the NSString methods, then you could convert a C string into a
NSString, do your manipulations, and convert back to a C string.
That's quite costly (you have to copy in and out, there may be
conversions of encoding, etc), and you would do that only if you have
really complicated needs better done with NSString than with
string.h...
{ char* cstring;
NSMutableString* buffer=[NSMutableStrin stringWithCString:"Hello World!"];
NSRange r={3,7};
[buffer deleteCharactersInRange:r];
cstring=[buffer lossyCString];
}
--
__Pascal_Bourguignon__ http://www.informatimago.com/
----------------------------------------------------------------------
Do not adjust your mind, there is a fault in reality.
- stupide question, reuss, 2003/08/22
- stupide question,
Pascal Bourguignon <=
- Message not available