小编hem*_*ant的帖子

逐个添加不同的字符到NSString?

我正在使用thsi函数从字符串中检索不同的字符,并向它们添加5以显示相应的字符,例如.'a'显示'f'和'h'显示'm'..但问题是我无法将这些字符添加到字符串中,我可以使用它来显示像'fm'...可以任何人救命??继承人代码strResult(mutablestring)仅获得null.

str=@"John";

int a=[str length];

for(i=0;i<a;i++)
{
  char ch=[str characterAtIndex:i];
  ch=ch+5;
  temp=[NSString stringWithFormat:@"%c",ch];
  [strResult appendString:temp];
  NSLog(@"%c",ch);
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c

5
推荐指数
1
解决办法
1万
查看次数

如何在目标c中获得特定的一周?

使用公历,我可以得到星期几的数字(即星期日为1,星期一为2等),但我找不到显示星期名称的函数.有人可以帮忙吗?

这是我获取天数的代码:

NSDate *dates = [gregorian dateFromComponents:component];

NSDateComponents *weekdayComponents =[gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit) fromDate:dates];

NSUInteger *weekdays = [weekdayComponents weekday]; 


NSString *dayw=[NSString stringWithFormat:@"%1i",weekdays];

NSLog(@"%@",dayw);
Run Code Online (Sandbox Code Playgroud)

iphone objective-c

2
推荐指数
1
解决办法
1580
查看次数

标签 统计

iphone ×2

objective-c ×2