iOS开发的字符串排序和计算格林时间代码实例
程序员文章站
2022-07-06 08:05:08
ios字符串排序和计算格林时间代码实例
//字符串排序
- (nsstring*)signkey:(nsstring *)params
{
nsmutablestrin...
ios字符串排序和计算格林时间代码实例
//字符串排序 - (nsstring*)signkey:(nsstring *)params { nsmutablestring *parammustr = [nsmutablestring string]; nsmutablearray *paramsmuarr = [[nsmutablearray alloc] init]; for (int i = 0; i<params.length; i++) { unichar c = [params characteratindex:i]; nsstring * cstr = [nsstring stringwithcharacters:&c length:1]; [paramsmuarr addobject:cstr]; } nsarray *paramsarr = [paramsmuarr sortedarrayusingselector:@selector(compare:)]; for (int j = 0; j<[paramsarr count]; j++) { [parammustr appendstring:paramsarr[j]]; } return parammustr; } //计算格林时间 nsdate* dat = [nsdate datewithtimeintervalsincenow:0]; nstimeinterval a=[dat timeintervalsince1970] * 1000; nsstring *timestt = [nsstring stringwithformat:@"%.0f", a];
上一篇: 在非洲工作