Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
stringByAddingPercentEncodingWithAllowedCharacters Crash
#import <Foundation/Foundation.h>
int main(int argc, char * argv[]) {
@autoreleasepool {
NSString *s1 = @"对于Launcher这类产品来说,它很容易让人们陷入这是工具还是平台的争执中。不过在李涛看来,这种争执完全是一个伪命题,因为一款产品用的人多了它自然就是平台,用的人少了它什么都不是。基于此,李涛其实并没有过多的去考虑APUS Launcher要做平台还是工具,他想的更多的是如何解决用户的问题。作为一个即用iOS又用Android的用户,我本人的一个体会就是iPhone会给人一种你越用越觉得它好用的感觉,但Android就不会。所以APUS Launcher现在就要解决这个难题,让Android变得好用。这也是为何李涛会说自己做的不是一个Launcher而是一套“用户系统”。";
NSString *s2 = [s1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// crash with iOS 8.1 SDK!
NSString *s3 = [s1 stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
NSLog(@"%@", s2);
NSLog(@"%@", s3);
return 0;
}
}
test: main.m
gcc -o main main.m -framework Foundation

fengsp commented Nov 27, 2014

Have no idea about what does @ symbol stand for.

jokingme commented Jan 4, 2016

I have no idea how to use stringByAddingPercentEncodingWithAllowedCharacters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment