objective c的字符串变量怎么定义
2个回答
展开全部
可以用NSMutableString
例如:
NSMutableString * str = [[NSMutableString alloc] initWithCapacity:128];
下面是苹果公司网站上查到的用法:
(链接:https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSMutableString_Class/index.html#//apple_ref/occ/instm/NSMutableString/initWithCapacity:)
Returns an NSMutableString object initialized with initial storage for a given number of characters,
Declaration
Swift
init(capacity capacity: Int)
Objective-C
- (NSMutableString *)initWithCapacity:(NSUInteger)capacity
Parameters
capacity
The number of characters the string is expected to initially contain.
Return Value
An initialized NSMutableString object with initial storage for capacity characters. The returned object might be different than the original receiver.
Discussion
The number of characters indicated by capacity is simply a hint to increase the efficiency of data storage. The value does not limit the length of the string.
例如:
NSMutableString * str = [[NSMutableString alloc] initWithCapacity:128];
下面是苹果公司网站上查到的用法:
(链接:https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSMutableString_Class/index.html#//apple_ref/occ/instm/NSMutableString/initWithCapacity:)
Returns an NSMutableString object initialized with initial storage for a given number of characters,
Declaration
Swift
init(capacity capacity: Int)
Objective-C
- (NSMutableString *)initWithCapacity:(NSUInteger)capacity
Parameters
capacity
The number of characters the string is expected to initially contain.
Return Value
An initialized NSMutableString object with initial storage for capacity characters. The returned object might be different than the original receiver.
Discussion
The number of characters indicated by capacity is simply a hint to increase the efficiency of data storage. The value does not limit the length of the string.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询