0으로 시작하고

9-10자리

숫자


1. 숫자만 추출하여

2. 정규표현식으로 체크


    NSString *phoneNumber = @"03-3200-2222";

    

    phoneNumber = [[phoneNumber componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet]invertedSet]]componentsJoinedByString:@""];

    

    NSString *someRegexp = @"^0\\d{9,10}$";

    NSPredicate *myTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", someRegexp];

    

    if ([myTest evaluateWithObject: phoneNumber]){

        //Matches

        NSLog(@"it is a phone number");

    }else{

        NSLog(@"it is NOT a phone number");

    }






Posted by tenn
,

[objc] NSNull check

iPhone 2013. 4. 18. 20:38

JSON에서 받은 값에서 NULL의 값은

NSNull로 돌아오는데.

그 체크를 하려면



if
(title == (id)[NSNull null] || title.length == 0 ) title = @"Something";




http://stackoverflow.com/questions/968792/what-is-the-right-way-to-check-for-a-null-string-in-objective-c






Posted by tenn
,


UIView : 배경. 경고창이외를 만질 때, 이벤트를 무시하기 위한

UIView : 경고창

UITextView : 메세지표시를 위한

UIButton : 경고창 버튼


1. 배경(UIView)에 경고창(UIView)을 붙여주고.

2. UITextView에 메세지를 넣고

3. UIView에 UITextView를 붙임

4. UITextView의 높이를 컨텐츠 높이로 재조정

5. UIView의 높이를 UITextView의 높이에 따라 재조정

6. 취향에 따라 버튼을 붙여준다.


Posted by tenn
,