ios - NSAttributedStringKey.attachment versus NSAttachmentAttributeName -
i'm having problems nsattributedstringkey.attachment versus nsattachmentattributename. here's relevant code:
var key: any? if #available(ios 11, *) { key = nsattributedstringkey.attachment } else { key = nsattachmentattributename }
one of 2 things happening. in actual place i'm trying use code (a cococapod of own design, deployment target of ios 8 , building xcode 9), error:
type 'nsattributedstringkey' (aka 'nsstring') has no member 'attachment'
or, if make new example project , set deployment target @ ios 8, get:
'nsattachmentattributename' has been renamed 'nsattributedstringkey.attachment'
this not behavior i'd expect #available
. thoughts?
this string
vs struct
difference between swift 3 (uses string
s such nsattachmentattributename
) , swift 4 (uses struct static attributes such nsattributedstringkey.attachment
), not between ios <11 , ios >=11. instance, can use nsattributedstringkey.attachment
, similar in supporting version of ios (e.g. .attachment
available since ios 7) within swift 4 project. #available
doesn't apply because it's swift language version difference rather os version difference.
ensure pod set correct swift version , should work expected. can tell cocoapods adding .swift-version
file @ top of project:
$ echo 4.0 >.swift-version
this magical version file mentioned in passing in cocoapods blog post last year: http://blog.cocoapods.org/cocoapods-1.1.0/
Comments
Post a Comment