I changed my Apple ID (email address) at appleid.apple.com because I will be losing access to my old Apple ID email address. Regrettably, however, when I made the change I was currently signed on to iCloud on my iMac using my old Apple ID.
When I realized this I tried to sign out of my old Apple ID (using System Preferences --> iCloud). While doing so I discovered that the 'Find My Mac' iCloud feature was ON, and before I could sign out of my old Apple ID I had to turn off Find My Mac. So I cleared the checkbox for that feature. Then a dialog pops up telling me I have to enter my Apple ID password in order to turn off Find My Mac. No problem, I thought, and I entered my password for my old Apple ID. Fail! The dialog tells me 'Your Apple ID or password is incorrect.' Of course I repeated this effort several times to be sure I was entering my password correctly (I have no doubt I know my password for the old Apple ID). I also tried the password for my new Apple ID. Nothing worked. The problem, I surmise, is my old Apple, not the password. The old ID is no longer recognized even though System Preferences --> iCloud shows that is the one under which I am signed in.
I'm very sorry for any confusion about iCloud sync! The reason iCloud sync is only available in the Mac App Store version of 1Password 5 for Mac is because it uses Apple's new CloudKit technology, which can only be used by apps sold through the Mac App Store. Sign in to iCloud to access your photos, videos, documents, notes, contacts, and more. Use your Apple ID or create a new account to start using Apple services. Apple suffered a sweeping services outage on Tuesday night, with major platforms like the App Store, Apple Music, Apple Arcade, iCloud and others rendered inaccessible for several hours.
So, it seems I'm signed in to iCloud under my old Apple ID, but I cannot sign out because I have to enter my password to turn off Find My Mac, and my password does not work because my old Apple ID is no longer recognized.
https://brownmonster278.weebly.com/blog/map-maker-app-mac. I've spent several hours over two day searching for solutions on the web, and I see that many others have had the same or a very similar problem, and several solutions have been suggested (which are too numerous and lengthy to repeat here). I've tried all the suggested solutions and none have worked for me.
Help! If you have any ideas I'm eager to try them.
I'm running macOS Sierra 10.12.2 on a late 2009 27' iMac.
By the way, my Apple ID change was successfully updated automatically or manually by me on my iPhone, my iPad, and my Apple TV. Even on my iMac my Apple ID was updated for the App store. But I no longer have access to iCloud on my iMac.
iMac, macOS Sierra (10.12.2), Bootcamp 3.2, Windows 7
Posted on
![]()
Ubi–what!? With the
NSUbiquitousKeyValueStore you can sync key-value store data across iOS and Mac devices, via iCloud. It’s perfect for persisting user preferences to iCloud, and it’s simple to set up.
In this article you’ll learn:
Ready? Let’s go.
What’s A Key-Value Store?
A key-value store is a container that stores data items. Every data item has a key and a value. You can read a value from the key-value store by using its associated key.
The simplest key-value store is a dictionary or array, where values are associated with keys and indices respectively. You can compare it to an address book, where you look up a person’s address (a value) by using their name (a key).
Let’s look at an example:
let kvs = [
'name': 'John Appleseed', 'address': '1 Infinite Loop Cupertino, CA 95014', 'country': 'United States', 'planet': 'Earth', 'sector': 'Sector ZZ9 Plural Z Alpha' ] print('sector = (kvs['sector']!)')
The dictionary
kvs has five key-value pairs, such as key 'planet' has value 'Earth' . In the above example, the keys and values of kvs both are of type String .
On the last line of the example, we’re printing out the value of
kvs['sector'] with Swift’s subscript syntax. It will print out the value for key 'sector' , i.e. Sector ZZ9 Plural Z Alpha.
Key-value stores are important in software development and apps, because they provide a simple way to store “flat” data. Unlike relational databases like MySQL, you can’t use a key-value store to organize relationships between data entries.
Associating keys with values in software development isn’t particularly novel or exciting. What makes key-value stores so interesting is that they come with a number of additional features, such as synchronization, distribution across devices, high-performance lookups, and even clustering for high-availability.
Plenty of key-value store tools exist outside of iOS development. Take Redis for example, which is an “in-memory data structure store.” It has replication and clustering, supports many different data formats, and it’s an all-round beast when it comes to web-based key-value storage.
In this article, we’re going to work with a key-value store that’s persisted via iCloud. It’s perfect to read and write key-value data, and sync it across iCloud-enabled devices. And it persists data between https://brownmonster278.weebly.com/blog/how-to-lock-specific-apps-on-mac. app installs, which makes it particularly handy for configuring apps.
Learn how to build iOS appsGet started with iOS 14 and Swift 5
Sign up for my iOS development course, and learn how to build great iOS 14 apps with Swift 5 and Xcode 12.
Writing Data To iCloud Key-Value Store
The class we’re working with here is called
NSUbiquitousKeyValueStore . It’s a bit of a mouth full, so let’s break it down:
The
NSUbiquitousKeyValueStore is very similar to UserDefaults. In fact, UserDefaults is a key-value store too. The big difference is that UserDefaults only stores data locally in your app, and won’t sync it across devices.
Just as
UserDefaults , the NSUbiquitousKeyValueStore has a .default class property that we can use to read from and write to the default key-value store.
Hype 3 mac app. Writing to the key-value store is as simple as:
The above code sets a value for a particular key. The iCloud key-value store can handle several data types, such as
Bool , Data , Dictionary , Array , String , Double , Date and Int .
There are some limits to the size of data you can store:
If you’re only using the iCloud key-value store to save simple text-based configuration values, you won’t exceed these limits. If you’re looking to store large amounts of data, i.e. a user’s content, or images, don’t use
NSUbiquitousKeyValueStore .
To use
NSUbiquitousKeyValueStore , you’ll need to distribute your app through the iOS or Mac App Store. You must also set the com.apple.developer.ubiquity-kvstore-identifier entitlement in your app’s Entitlements. You can find your app’s entitlements in Xcode, by going to ProjectSettings -> Capabilities . Enable the iCloud capability and check Key-value storage. You might need to enable iCloud for your App ID too, by going to Certificates, Identifiers & Profiles on developer.apple.com/account.
Fun Fact:UTF-8 is a multi-byte encoding for text. You can compare encoding to using a dictionary to map byte values to human-readable characters. UTF-8 takes 1 to 4 bytes per character, with the first 128 ASCII characters only needing one byte. In short, you can fit 64 alphanumeric characters in 64 bytes of a UTF-8 string. You’ll need 2 bytes for diacritic characters (accents), and languages like Greek and Cyrillic. You’ll need 3 bytes for most Japanese, Chinese and Korean characters. And last but not least: 4 bytes for emoji… In short, if you use simple strings like
'address' , you’ve got plenty of space.
Reading Data From iCloud Key-Value Store
Reading data from the iCloud key-value store is simple, too. Like this:
Unlike the
set(_:forKey:) function, the functions to read data from the key-value store use the type of the value explicitly in the function name. So, you can use these functions to read different types from the key-value store:
Most of the functions above return optionals. If a key doesn’t exist, the return value is
nil . Notable exceptions are bool(forKey:) , double(forKey:) and longLong(forKey:) .
If the function returns an optional, you can use the nil-coalescing operator
?? to provide a default value:
And you can also use optional binding to validate data, like this:
Removing key-value pairs is as simple as:
Depending on the architecture of your app, it might be smart to create a separate API or interface to interact with
NSUbiquitousKeyValueStore .
What you don’t want, is sprinkling code that reads from and writes to the key-value store throughout your view controllers, for instance. A separate API will also help you migrate to another key-value store tool, if needed.
What’s also smart, is to create central structures for the key names you use in
NSUbiquitousKeyValueStore , or UserDefaults . Instead of working with strings directly, you organize any key strings you might use in your app in one nested struct. Like this:
When you want to read from or write to the key-value store, using these constants will save you from accidentally making typos. Like this:
Make a typo in
kUseDta and your code won’t compile, whereas for 'kUseDta' you’re going to pull your hairs out searching for that typo…
Responding To Data Changes From iCloud
The difference between
NSUbiquitousKeyValueStore and UserDefaults is that the ubiquitous key-value store (what a name!) synchronizes to iCloud. This essentially means that iOS will upload the key-value store to iCloud when you write something to it, and download that same key-value store into another install of the same app.
The data in the key-value store is persisted between app installs – so it’ll be there even if you uninstall the app – and it’s synced between devices. You can even share the data store between iOS and Mac apps that have the same identifier.
Before we find out how synchronization works, what would you use a synced key-value store for? Some ideas:
Icloud Mac Download
Just like
UserDefaults , you don’t have to actively synchronize the key-value store on the device. Here’s how that works:
Pushing to iCloud goes automatically. You can call
synchronize() explicitly to sync the in-memory key-value store with the data on the disk. Like this:
You can also observe changes to the iCloud data store in your app. Whenever data changes, a notification is sent to a function you specify, which includes the keys that have been changed. This mechanism uses NotificationCenter.
Here’s how you register for those changes:
It’s a bit of a beast. Here’s what it does:
And here’s that function:
Inside that function you can use the
notification parameter to get information about the pushed key-value data, via its userInfo property. Such as:
You can also get the key-value data store object that’s changed, via
notification.object . This is especially helpful if you’re working with multiple NSUbiquitousKeyValueStore objects.
Learn how to build iOS appsIcloud Mac App Store SettingsGet started with iOS 14 and Swift 5Mac App Store Download Free
Sign up for my iOS development course, and learn how to build great iOS 14 apps with Swift 5 and Xcode 12.
Further ReadingIcloud Mac App Store For Windows
That’s all there is to it! Reading and writing data with the iCloud data store is surprisingly simple. The
NSUbiquitousKeyValueStore is ideal for syncing key-value store data between iOS devices – and now you know exactly how it works.
Icloud Mac App
Want to learn more? Check out these resources:
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |