[swift-corelibs-dev] NSAttributedString attributesAtIndex return an optional.
Brent Royal-Gordon
brent at architechies.com
Tue Dec 8 08:39:35 CST 2015
> Been playing around with NSAttributedString and cannot decide on the best way to implement the (attributesAtIndex: effectiveRange) and other methods with similar functionality.
>
> In the ObjC world I would expect an empty NSDictionary even in cases where the location is greater than the length of the string.
Personally, if I indexed past the end of an attributed string, I would expect a precondition to fail and (since Swift can't catch assertion failures) my app to crash. (And from what I can tell, the Apple Foundation versions of these APIs do not return an optional.)
(Sorry about the duplicate, James—didn’t hit Reply All when I should have.)
--
Brent Royal-Gordon
Architechies
More information about the swift-corelibs-dev
mailing list