Saturday, May 18, 2013

NSString lowercaseString example ios


[NSString lowercaseString]

Returns lowercased representation of the receiver.
- (NSString *)lowercaseString
Return Value
A string with each character from the receiver changed to its corresponding lowercase value.
Discussion of [NSString lowercaseString]
Case transformations aren’t guaranteed to be symmetrical or to produce strings of the same lengths as the originals. The result of this statement:
lcString = [myString lowercaseString];
might not be equal to this statement:
lcString = [[myString uppercaseString] lowercaseString];
For example, the uppercase form of “ß” in German is “SS”, so converting “Straße” to uppercase, then lowercase, produces this sequence of strings:
  • “Straße”
  • “STRASSE”
  • “strasse”


Example of [NSString lowercaseString]

NSString *noCaps = [yourString lowercaseString];

Example of [NSString lowercaseString]
 NSString *input = @"ÁlgeBra";

  NSString *correctCase = [NSString stringWithFormat:@"%@%@",
                           [[input substringToIndex:1] uppercaseString],
                           [[input substringFromIndex:1] lowercaseString]];

  NSString *result = [[[NSString alloc] initWithData:[correctCase dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] encoding:NSASCIIStringEncoding] autorelease];

  NSLog( @"%@", result );
Example of [NSString lowercaseString]
NSString *original = @"blah"
 NSString *lowercase = [original lowercaseString];

NSString longLongValue example ios


[NSString longLongValue]

Returns the long long value of the receiver’s text.
- (long long)longLongValue
Return Value
The long long value of the receiver’s text, assuming a decimal representation and skipping whitespace at the beginning of the string. Returns LLONG_MAX orLLONG_MIN on overflow. Returns 0 if the receiver doesn’t begin with a valid decimal text representation of a number.
Discussion of [NSString longLongValue]
This method uses formatting information stored in the non-localized value; use anNSScanner object for localized scanning of numeric values from a string.
Example of [NSString longLongValue]
NSString * theString = [[[_message objectForKey:@"user"] objectForKey:@"id"];

NSNumberFormatter * numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
NSNumber * number = [numberFormatter numberFromString:theString];

NSLog(@"%llu", [number unsignedLongLongValue]);
Example of [NSString longLongValue]
NSString *numStr = [NSString stringWithFormat:@"%llu", [myNum unsignedLongLongValue]];

// .. code and time in between when numStr was created
// .. and now needs to be converted back to a long long.
// .. Therefore, numStr used below does not imply the same numStr above.

unsigned long long ullvalue = strtoull([numStr UTF8String], NULL, 0);
Example of [NSString longLongValue]
long long int numC;

//Number formatter and string operations

numC = [valuestring longLongValue];

NSString *results = [formatter stringFromNumber:[NSNumber numberWithLongLong: numC]];    
label1.text = results;

NSString localizedStandardCompare example ios


[NSString localizedStandardCompare]

Compares strings as sorted by the Finder.
- (NSComparisonResult)localizedStandardCompare:(NSString *)string
Parameters
string
The string to compare with the receiver.
Return Value
The result of the comparison.
Discussion of [NSString localizedStandardCompare]
This method should be used whenever file names or other strings are presented in lists and tables where Finder-like sorting is appropriate. The exact sorting behavior of this method is different under different locales and may be changed in future releases.
Example of [NSString localizedStandardCompare]
NSArray *sorted = [foo sortedArrayUsingComparator:^NSComparisonResult(NSString *str1, NSString *str2) {
    // Remove all spaces
    NSString *s1 = [str1 stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSString *s2 = [str2 stringByReplacingOccurrencesOfString:@" " withString:@""];

    return [s1 localizedStandardCompare:s2];
}];
Example of [NSString localizedStandardCompare]
NSArray *sortedValues = [[yourDictionary allValues] sortedArrayUsingSelector:@selector(localizedStandardCompare:)];
NSMutableDictionary *orderedDictionary=[[NSMutableDictionary alloc]init];
for(NSString *valor in sortedValues){
    for(NSString *clave in [yourDictionary allKeys]){
        if ([valor isEqualToString:[yourDictionary valueForKey:clave]]) {
            [orderedDictionary setValue:valor forKey:clave];
        }
    }
}
Example of [NSString localizedStandardCompare]
sortedArray = [anArray sortedArrayUsingSelector:@selector(localizedStandardCompare:)];

NSString localizedCompare example ios


[NSString localizedCompare]

Returns an NSComparisonResult value that indicates the lexical ordering of the receiver and another given string using a localized comparison.
- (NSComparisonResult)localizedCompare:(NSString *)aString
Parameters
aString
The string with which to compare the receiver.
This value must not be nil. If this value is nil, the behavior is undefined and may change in future versions of OS X.
Return Value of [NSString localizedCompare]
NSOrderedAscending the receiver precedes string in lexical ordering,NSOrderedSame the receiver and string are equivalent in lexical value, andNSOrderedDescending if the receiver follows string.

Example of [NSString localizedCompare]
NSArray *sorted = [foo sortedArrayUsingComparator:^NSComparisonResult(NSString *str1, NSString *str2) {
    // Remove all spaces
    NSString *s1 = [str1 stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSString *s2 = [str2 stringByReplacingOccurrencesOfString:@" " withString:@""];

    return [s1 localizedCompare:s2];
}];
Example of [NSString localizedCompare]
NSArray *sortedValues = [[yourDictionary allValues] sortedArrayUsingSelector:@selector(localizedCompare:)];
NSMutableDictionary *orderedDictionary=[[NSMutableDictionary alloc]init];
for(NSString *valor in sortedValues){
    for(NSString *clave in [yourDictionary allKeys]){
        if ([valor isEqualToString:[yourDictionary valueForKey:clave]]) {
            [orderedDictionary setValue:valor forKey:clave];
        }
    }
}
Example of [NSString localizedCompare]
sortedArray = [anArray sortedArrayUsingSelector:@selector(localizedCompare:)];