Javascript与Objective-C 字符串与数组的方法类比

String vs NSString

JavaScript string Obj-C NSString
charAt(index) (see text)
charCodeAt(index) - (unichar)characterAtIndex:(NSUInteger)index
concat(string) - (NSString *)stringByAppendingString:(NSString *)aString
indexOf(string) - (NSRange)rangeOfString:(NSString *)aString
lastIndexOf(string) - (NSRange)rangeOfString:(NSString *)aString options:NSBackwardsSearch
localeCompare(string) - (NSComparisonResult)localizedCompare:(NSString *)aString
split(delimiter) - (NSArray *)componentsSeparatedByString:(NSString *)separator
substring(startIndex) - (NSString *)substringWithRange:(NSRange)aRange
toLowerCase() - (NSString *)lowercaseString
toUpperCase() - (NSString *)uppercaseString

 

Array vs NSArray

JavaScript Array Obj-C NSArray
length - (NSUInteger)count
concat(item1[, item2...]) - (NSArray *)arrayByAddingObject:(id)anObject
-(NSArray *)arrayByAddingObjectsFromArray:(NSArray *)otherArray
join(delimiter) - (NSString *)componentsJoinedByString:(NSString *)separator
sort()

- (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(id, id, void
*))comparator context:(void *)context

toString() - (NSString *)description

 

摘自:Learning the iOS 4 SDK for JavaScript Programmers  

 PDF下载>>

posted @ 2015-06-03 14:40  meteoric_cry  阅读(542)  评论(0编辑  收藏  举报