macOS/iOS API解説

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

目次

string

スキャナの文字列を返します

解説

スキャナの文字列を返します。

返り値

( NSString * )

文字列

引数

クラス

NSScanner

Instance Methods

使用可能

10.0

参照

- locale

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
    //NSScannerを作る
    NSScanner *scanString = [[NSScanner alloc]
                initWithString:@"300"];
    NSMutableString *str;//文字を作る
    NSDecimalNumber *dNum = [[[NSDecimalNumber alloc] autorelease] initWithString:@"300"];
    NSDecimal dec = [dNum decimalValue];
    //NSSCannerの文字列
    NSLog([NSString stringWithFormat:@"string %@",[scanString string]]);
    
    if ([scanString scanDecimal:&dec]){
    NSLog(@"scanDecimal YES");
    }else{
    NSLog(@"scanDecimal NO");
    }
    NSLog([NSString stringWithFormat:@"location %d",[scanString scanLocation]]);
    
    [scanString setScanLocation: 1 ];
    [scanString setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@"\"'"]];
    [scanString scanUpToString:@"\n" intoString:&str];

    [myOutlet setStringValue:str];

NSLog([[scanString locale] description]);
}

@end