Skip to content

add Foundation NSMutableDictionary#53

Merged
teach310 merged 2 commits intofeature/central_manager_init_optionsfrom
feature/ns_mutable_dictionary
Oct 25, 2023
Merged

add Foundation NSMutableDictionary#53
teach310 merged 2 commits intofeature/central_manager_init_optionsfrom
feature/ns_mutable_dictionary

Conversation

@teach310
Copy link
Copy Markdown
Owner

@teach310 teach310 commented Oct 25, 2023

Description

add NSMutableDictionary
optionで使う

NSMutableDictionaryが必要な理由

swiftのDictionaryはクラスじゃないから。
https://developer.apple.com/documentation/swift/dictionary

Unmanaged.passRetainの引数にするためにはクラスである必要がある。

NSMutableDictionaryからswift Dictionaryへの変換

基本的には as でできる。
ただしbool値に関してはNSNumberのため変換後に入るのが数値。
0,1 ではなく false, trueの値が必要な場合には変換用の関数を自前で作る必要がある。
今回はなかった。

Test

テストコード

teach310 added 2 commits October 26, 2023 00:42
## NSMutableDictionaryが必要な理由

swiftのDictionaryはクラスじゃないから。
https://developer.apple.com/documentation/swift/dictionary

Unmanaged.passRetainの引数にするためにはクラスである必要がある。

## NSMutableDictionaryからswift Dictionaryへの変換

基本的には as でできる。
ただしbool値に関してはNSNumberのため変換後に入るのが数値。
0,1 ではなく false, trueの値が必要な場合には変換用の関数を自前で作る必要がある。
今回はなかった。
@teach310 teach310 added the add label Oct 25, 2023
@teach310 teach310 merged commit 4d1e3d2 into feature/central_manager_init_options Oct 25, 2023
@teach310 teach310 deleted the feature/ns_mutable_dictionary branch October 25, 2023 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant