我需要NSData从vendorIdentifier没有转化为NSString清晰的字节.如何转换NSUUID使用getUUIDBytes:到NSData?
比较两者的最佳(最少代码,最快,最可靠)方法是NSUUIDs什么?
这是一个例子:
-(BOOL)isUUID:(NSUUID*)uuid1 equalToUUID:(NSUUID*)uuid2
{
return ... // YES if same or NO if not same
}
Run Code Online (Sandbox Code Playgroud) MSConversation为我们提供了本地参与者和远程参与者.但是,我无法检索自己或其他人的显示名称.我如何得到这些名字? https://developer.apple.com/reference/messages/msconversation
let ids = activeConversation?.remoteParticipantIdentifiers
let otherId = ids?[0].uuidString
let ownId = activeConversation?.localParticipantIdentifier.uuidString
let predicate = CNContact.predicateForContacts(withIdentifiers: [otherId!]);
do {
let contacts = try CNContactStore().unifiedContacts(matching: predicate, keysToFetch: [CNContactFamilyNameKey, CNContactGivenNameKey, CNContactNicknameKey, CNContactIdentifierKey])
for contact in contacts{
print(contact.givenName)
print(contact.familyName)
print(contact.identifier)
}
} catch let err{
print(err)
}
Run Code Online (Sandbox Code Playgroud)
如上所述,我试图搜索CNContactsStore,MSConversation中的UUID与CNContact不同.
我正在开发iOS Swift.
我已将NSUUID转换为String,如下所示:
var bdAddr:NSUUID?
var text:String = bdAddr!.UUIDString
Run Code Online (Sandbox Code Playgroud)
但是如何在Swift中将String转换为NSUUID?
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
Run Code Online (Sandbox Code Playgroud)
这会改变吗?我原本想使用MAC地址,但显然7+不会返回它.我从我正在处理的开发应用程序中调用了这个,并读取它是使用bundle id计算的.
发布应用程序商店后,这将永远保持一致吗?