Attempt to set a plist value error on registering Dictionary of Ints with NSUserDefaults

I have the following snippet of code that is causing my app to crash:

let defaults = [1 : 0]

Which gives me the following error:

'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object {
1 = 0;
} for key highScores'

I don't get it though. Why wouldn't [1 : 0] be a plist? It is made up of Ints stored in a Dictionary.


Quote from Apple docs:

And although NSDictionary and CFDictionary objects allow their keys to be objects of any type, if the keys are not string objects, the collections are not property-list objects

Your code should work by substituting let defaults = ["1" : 0] for your first assignment.

Need Your Help

What is best practice as far as using perl-isms (idiomatic expressions) in Perl?

perl coding-style idiomatic-perl

A couple of years back I participated in writing the best practices/coding style for our (fairly large and often Perl-using) company. It was done by a committee of "senior" Perl developers.

Cannot invoke '-' with with an argument of type(IntegerLiteralConvertible… (IOS / Swift)

ios swift

im getting an error but i dont understand what the issue is. I'm quite new with IOS / Swift development.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.