wuf*_*foo 0 iphone nsstring ios
新的ios并尝试从函数返回NSString.据我了解,我需要[NSString... alloc] init]为了返回创建字符串.此外,因为我打电话alloc,我想我必须自己自动释放该对象,但是我收到消息"ARC禁止'autorelease'的显式消息发送"所以..当我完成分配的NSString时,我怎么告诉ios ?
- (NSString *) generateUID
{
char foo[32];
// create buffer of all capital psuedo-random letters
for (int i = 0; i < sizeof(foo); i++)
foo[i] = (random() % 25) + 65; // 0-25 + CAPITAL_A
NSString *uid = [[NSString alloc] initWithBytes:foo length:sizeof(foo) encoding:NSASCIIStringEncoding];
NSLog (@"uid: %@", uid);
return (uid);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4440 次 |
| 最近记录: |