随手记_判断纯中文,密码有效性检查,时间排序,发布应用程序,推送,判断网络

来源:互联网 发布:桌面软件管理软件 编辑:程序博客网 时间:2024/05/19 12:23

IOS    记下来以后用

1、判断纯中文

+ (BOOL) validateNickname:(NSString *)nickname

{

    NSString *nicknameRegex = @"^[\u4e00-\u9fa5]{1,4}$";

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", nicknameRegex];

    BOOL isMatch = [pred evaluateWithObject:nickname];

    return isMatch;


}

//{1,4}是1到4个汉字

2、密码有效性检查


+ (BOOL)isPassword:(NSString *)password

{

    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^[a-zA-Z0-9]{6,30}$"options:NSRegularExpressionCaseInsensitive error:nil];

    if (regex != nil) {

        NSUInteger numberOfMatch = [regex numberOfMatchesInString:password options:0 range:NSMakeRange(0, [password length])];

        if (numberOfMatch == 0) {

            return NO;

        }

    }

    return  YES;

    

}


3、按照时间排序


for (int i = 0; i < count; i++)
        {//将数据添加进数组中
            NSObject *object = [self.bubbleDataSource bubbleTableView:self dataForRow:i];
            assert([object isKindOfClass:[NSBubbleData class]]);
            [bubbleData addObject:object];
        }
        
        [bubbleData sortUsingComparator:^NSComparisonResult(id obj1, id obj2)//取数组中得实例进行判断
         {
             NSBubbleData *bubbleData1 = (NSBubbleData *)obj1;
             NSBubbleData *bubbleData2 = (NSBubbleData *)obj2;
             
             NSDateFormatter *inputFormatter = [[[NSDateFormatter alloc] init]autorelease];
             [inputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
             NSDate* inputDate1 = [inputFormatter dateFromString:bubbleData1._date];
             NSLog(@"date = %@", inputDate1);
             
             NSDate* inputDate2 = [inputFormatter dateFromString:bubbleData2._date];
             NSLog(@"date = %@", inputDate2);
             
             return [inputDate1 compare:inputDate2];
             //return [bubbleData1.date compare:bubbleData2.date];
         }];

//返回排序好后的数组

4、

iOS 发布应用程序到App Store


                            http://my.oschina.net/joanfen/blog/133642




5、推送   http://developer.baidu.com/wiki/index.php?title=docs/cplat/push/guideios&qq-pf-to=pcqq.c2c

http://www.apkbus.com/android-131635-1-1.html


6、判断当前网络是否存在

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-(BOOL)isExistenceNetwork
{
    BOOLisExistenceNetwork;
    Reachability*r = [ReachabilityreachabilityWithHostName:@"http://www.code4app.com"];
    switch([rcurrentReachabilityStatus]) {
        caseNotReachable:
            isExistenceNetwork=FALSE;
            break;
        caseReachableViaWWAN:
            isExistenceNetwork=TRUE;
            break;
        caseReachableViaWiFi:
            isExistenceNetwork=TRUE;
            break;
    }
     
    returnisExistenceNetwork;
}
有用3没用0
2

0 0
原创粉丝点击