简体   繁体   中英

Font and Font Size Changing

I have a Mac app with a plain-text text view. I have been able to get it to save, etc, but when I change the font or font size in my app using the font panel, it is not saved when the app re-opens.

How can I create a way that my app will save the font and font size changes? Thanks!

Save Font and Font Size in NSUserDefaults and load from NSUserDefault at the time of application launching.

NSString *valueToSave = @"someValue";
[[NSUserDefaults standardUserDefaults]
    setObject:valueToSave forKey:@"preferenceName"];
to get it back later

NSString *savedValue = [[NSUserDefaults standardUserDefaults]
    stringForKey:@"preferenceName"];

Take a look at Save string to the NSUserDefaults? post.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM