NSUserDefaults in monotouch

Posted by Ali Shafai on Stack Overflow See other posts from Stack Overflow or by Ali Shafai
Published on 2010-04-09T01:28:05Z Indexed on 2010/04/09 1:33 UTC
Read the original article Hit count: 811

Filed under:

I'm very impressed with MonoTouch.Dialog by Miguel. inspired by his simple approach I thought it would be very nice to have a reflection based NSUserDefaults class that works seamlessly by marking certain properties as "persistable in user defaults" and forget about the rest. something like this:

    public class SomeController
    {
        [PersistInUserSettings]
        public string LastPostUserRead { get; set; }
    }

I don't like the LastPostUserRead to be of type "UserSetting", I like it to be a normal property so that later I can assign to it like:

LastPostUserRead = "Post 1";

and not like:

LastPostUserRead.SetValue("Post 1");

Any idea on how to implement it (without Reflection.Emit) in monotouch?

© Stack Overflow or respective owner

Related posts about monotouch