Tuesday, December 12, 2017

#1 2015-10-02 10:20:59 am

Mark Munro
Member
Registered: 2008-01-16
Posts: 175
Website

NSTaggedPointerString?

I have a text field with its value bound to a property.

When the value of the text field has no spaces, the class of the property is

Applescript:

property textComputerAdmin : ""

log my textComputerAdmin
-- Result = "Admin"

log class of my textComputerAdmin
-- Result = <NSAppleEventDescriptor: 'ctxt'>

When a space is present in the text field, suddenly the class of the property is NSTaggedPointerString.

Applescript:

property textComputerAdmin : ""

log my textComputerAdmin
-- Result = "Mark Munro"

log class of textComputerAdmin
-- Result = NSTaggedPointerString

When I try using this value, even just trying to set it "as text" as I get errors like:

Can’t make «class ocid» id «data optr00000000A5A32C389F2C6802» into type list, record or text.

I see no entry in Xcode's documentation for NSTaggedPointerString and web searches are fruitless. Does anyone know what is going on?

Offline

 

#2 2015-10-02 01:31:48 pm

Mark FX
Member
From:: UK
Registered: 2011-08-12
Posts: 94

Re: NSTaggedPointerString?

I found this article on NSTaggedPointerString's.

https://www.mikeash.com/pyblog/friday-q … rings.html

The article is very in depth on the subject, but it seems they where introduced in OS X 10.10 for memory and speed performances.
They also seem to be related to small sized String's, and String's stored in Array's.
Sorry I can't help you any more on the subject, as I hadn't heard of them myself until reading your post.

Regards Mark

Offline

 

#3 2015-10-02 06:51:20 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: NSTaggedPointerString?

Whatever your problem is, I'd be surprised if it's related to NSTaggedPointerString. You don't show how you are setting the values, but getting an AppleEventDescriptor in one case and an NSString in another suggests your code is a bit more complex.

Here's a simple snippet I'm running in ASObjC Explorer using BridgePlus to make sure I get a tagged pointer:

Applescript:

use framework "Foundation"
use script "BridgePlus"

set x to Cocoaify "Mark Munro"
x's |class|()
x as text

And here's what's logged:

Applescript:

0000.001 [8] set x to Cocoaify "Mark Munro"
-->    (NSString) "Mark Munro"
0000.001 [9] x's |class|()
-->    (Class) NSTaggedPointerString
0000.001 [10] x as text
-->    "Mark Munro"

So it seems to be coercing fine, as an NSString subclass should. I'm still running 10.11GM, but I doubt that matters.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)