macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

boolForKey:

ユーザーデフォルトからキーでBOOL値を取り出します
-(BOOL)boolForKey:(NSString *)defaultName:

解説

ユーザーデフォルトからキー(defaultName)でBOOL値を取り出します。

返り値

( BOOL )

取り出せたかYES/NO

引数

( NSString * )defaultName

取り出すキー

クラス

NSUserDefaults

Instance Methods

使用可能

10.0

参照

- arrayForKey:
- dataForKey:
- dictionaryForKey:
-floatForKey:
-integerForKey:
-objectForKey:
-stringArrayForKey:
-stringForKey:

例文

#import "SetImage.h"

@implementation SetImage

- (IBAction)set:(id)sender
{
    BOOL boo1 = YES;
    BOOL boo2 ;
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    
    [defaults setBool : boo1 forKey : @"settei1"];
 
 boo2 = [defaults boolForKey:@"settei1"];
 if(boo2){
 NSLog(@"YES");
 }else{
  NSLog(@"NO");
 }
}

@end