Objc bridge with NSAttributedString?

In the objc bridge I found:

objc. NSMutableStringProxyForMutableAttributedString

…which seems like somebody has created objective-C style attributed strings in Codea?

@Steppers?

Pretty much everything under the objc object is dynamic and generated using ObjC reflection at runtime (as I understand it)

According to this it’s part of the iOS SDK: https://developer.limneos.net/index.php?ios=11.0.1&framework=Foundation.framework&header=NSMutableStringProxyForMutableAttributedString.h

Huh. Ok darn. I was very curious to see someone implement NSMutableAttributedString!

UITextView supports attributed text :man_shrugging:t2:

I knows it, that’s why I was excited to see someone do it. I tried it myself but the objc bridge is tricky and said none of the methods I was trying to call existed.

Also all the documentation I tried to find online was swift, not objective C, and annoyingly Apple seems to have made it hard to find objective C reference material now.

So I was hopeful there was an example somewhere I could cheat off of.

@Steppers the idea occurred to me because your UIKit was cool, and listed all those fonts.

I wondered if I could make each font name print out using the font it named.

Technically it should be possible but I couldn’t figure it out, and ChatGPT couldn’t either.

At least, it couldn’t do it off of the prompt I wrote, maybe someone else could do better.

I’m eating my words!

I went back to take another swing at it and once I helped ChatGPT to understand how the special case objc.range command works—it did it!

The project now displays all available fonts in those fonts.

Zipped project attached. Thanks so much @Steppers

UIKit+NSAttributedString.zip (279.9 KB)

2 Likes

That’s fantastic, I’m glad you finally figured it out!