[Openmcl-devel] NSStrings

Randall Beer beer at eecs.cwru.edu
Wed Mar 3 07:14:59 PST 2004


%MAKE-NSSTRING allocates constant strings and you're apparently passing 
it into a method that wants to modify it.

  You might want to try something like:

(make-instance 'ns:ns-string :with-string #@"FOObarBAz")

which returns #<NS-CF-STRING "FOObarBAz" (#x45107930)>

Randy Beer



On Mar 3, 2004, at 8:57 AM, Paul D. Lathrop wrote:

> I am doing some work with the cocoa/objc bridge (for the Clotho 
> project) and I've come across some confusion involving passing a 
> string from the lisp to the objc runtime. What I am working on 
> currently is implementing a function that will swap the case of the 
> current selection. I am able to get the selection and change it's 
> case. I am then allocating an nsstring using the following form:
>
> (ccl::%make-nsstring new-string)
>
> new-string is the lispy form of the string I'm trying to send. The 
> problem is, when the string reaches the cocoa component I'm sending it 
> to, it has one character's worth of garbage appended to it. The lisp 
> doesn't see this garbage at all - it registers the nsstring as:
>
> #<NS-CONSTANT-STRING "FOObarBAz" (#x155190)>
>
> whereas, Cocoa gives me:
>
> "FOObarBAz¨"
>
> (note the extra char on the end). Am I missing a "proper" way of 
> accomplishing this? If not, what am I missing? The only clue I have 
> left is that the string I get *from* the objc runtime is:
>
> #<NS-CF-STRING "fooBARbaZ" (#x160B50)>
>
> Which is not what I am sending back. Could this be a problem? If it 
> is, how do I allocate the appropriate type of string? If I'm missing 
> something obvious, feel free to RTFM me.
>
> Thanks,
> Paul Lathrop
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>





More information about the Openmcl-devel mailing list