iphone-common-codes-ccteam源代码 CCIOS.m

//
// CCIOS.m
// CCFC
//
// Created by xichen on 11-12-17.
// Copyright 2011年 ccteam. All rights reserved.
//


#import "CCIOS.h"
#import "CCNSString.h"
#import "CCUIDevice.h"


@implementation CCIOS


//获取OS版本
+ (NSString *)osVersion
{
return [[UIDevice currentDevice] systemVersion];
}


// 获取OS主版本号
+ (NSString *)osMajorVer
{
NSString *osVer = [self osVersion];
if(osVer == nil)
return nil;

NSInteger index = [osVer firstIndexOfChar:'.'];
if(index < 0)
{
return osVer;
}
else if(0 == index)
{
return @"";
}
else
{
return [osVer substringToIndex:index];
}
}


// 获取OS子版本号
+ (NSString *)osMinorVer
{
NSString *osVer = [self osVersion];

NSInteger firstIndex = [osVer firstIndexOfChar:'.'];
NSInteger lastIndex = [osVer firstIndexOfChar:'.' withAppearCount:2];
if(firstIndex < 0)
{
return @"";
}
else if(lastIndex < 0)
{
if(firstIndex == osVer.length - 1)
{
return @"";
}
return [osVer substringWithRange:NSMakeRange(firstIndex + 1, osVer.length - firstIndex - 1)];
}
else
{
return [osVer substringWithRange:NSMakeRange(firstIndex + 1, lastIndex - firstIndex - 1)];
}
}


// whether the device supports multitask
+ (BOOL)isSupportsMultitask __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0)
{
return [UIDevice isSupportsMultitask];
}


@end

googlecode链接地址(会有更新):http://code.google.com/p/iphone-common-codes-ccteam/source/browse/trunk/CCFC/files/CCIOS.m

posted @ 2011-12-31 09:57  cc_team  阅读(223)  评论(0编辑  收藏  举报