tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,20 @@
#import <Foundation/Foundation.h>
@interface NSString (Extended)
-(NSString *)reverseString;
@end
@implementation NSString (Extended)
-(NSString *) reverseString
{
NSUInteger len = [self length];
NSMutableString *rtr=[NSMutableString stringWithCapacity:len];
// unichar buf[1];
while (len > (NSUInteger)0) {
unichar uch = [self characterAtIndex:--len];
[rtr appendString:[NSString stringWithCharacters:&uch length:1]];
}
return rtr;
}
@end

View file

@ -0,0 +1,11 @@
int main()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *test = [@"!A string to be reverted!" reverseString];
NSLog(@"%@", test);
[pool release];
return 0;
}

View file

@ -0,0 +1,20 @@
#import <Foundation/Foundation.h>
@interface NSString (Extended)
-(NSString *)reverseString;
@end
@implementation NSString (Extended)
-(NSString *)reverseString
{
NSInteger l = [self length] - 1;
NSMutableString *ostr = [NSMutableString stringWithCapacity:[self length]];
while (l >= 0)
{
NSRange range = [self rangeOfComposedCharacterSequenceAtIndex:l];
[ostr appendString:[self substringWithRange:range]];
l -= range.length;
}
return ostr;
}
@end

View file

@ -0,0 +1,11 @@
int main()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *test = [@"as⃝df̅" reverseString];
NSLog(@"%@", test);
[pool release];
return 0;
}