Check Current Orientation


if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft){
        //do something or rather
        NSLog(@"landscape left");
    }
    if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight){
        //do something or rather
        NSLog(@"landscape right");
    }
    if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait){
        //do something or rather
        NSLog(@"potrait");
    }
    if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown){
        //do something or rather
        NSLog(@"potrait upside down");
    }

Or you can also use this:

[[UIDevice currentDevice] orientation]

Swipe Gesture Recognizer


UISwipeGestureRecognizer * swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.delegate = self;
[self.view addGestureRecognizer:swipeRight];
[swipeRight release];
swipeRight = nil;

Make Animation Slow at the Beginning

[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
mainImage.alpha = 0.0f;
[UIView commitAnimations];

Details:
UIViewAnimationCurveEaseInOut: The default Value, slow at beginning and end of animation
UIViewAnimationCurveEaseIn: Slow at beginning, the speeds up
UIViewAnimationCurveEaseOut: Animation slows at end of animation
UIViewAnimationCurveLinear: Uniform speed throughout duration

Sort Array with comparator

For a mutable array of dictionaries:

NSMutableArray *aMutableArray = [NSMutableArray arrayWithObjects:
         [NSDictionary dictionaryWithObjectsAndKeys:
          @"A", @"name",
          [NSNumber numberWithInt:6], @"value", nil],
         [NSDictionary dictionaryWithObjectsAndKeys:
          @"C", @"name",
          [NSNumber numberWithInt:2], @"value", nil],
         [NSDictionary dictionaryWithObjectsAndKeys:
          @"B", @"name",
          [NSNumber numberWithInt:4], @"value", nil], nil];
In this case case here's how you sort it by value:


NSSortDescriptor *aSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"value" ascending:YES];
[aMutableArray sortUsingDescriptors:[NSArray arrayWithObject:aSortDescriptor]];



Otherwise:


NSSortDescriptor *lastNameDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastname" ascending:YES comparator:^(id left, id right) {
float v1 = [left floatValue];
float v2 = [right floatValue];
if (v1 < v2)
return NSOrderedAscending;
else if (v1 > v2)
return NSOrderedDescending;
else
return NSOrderedSame;
}];

[data sortUsingDescriptors:[NSArray arrayWithObject:lastNameDescriptor]];

sort an array of strings alphabetically when the strings contains åäö

NSArray *strings=[NSArray arrayWithObjects:@"as", @"ol", @"st", @"br", @"ög", @"år", @"ös", nil];
NSLocale *locale=[[NSLocale alloc] initWithLocaleIdentifier:@"sv_SE"];

NSArray *sorted=[strings sortedArrayUsingComparator:^(NSString *first, NSString *second) {
return [first compare:second
options:0
range:NSMakeRange(0, [first length])
locale:locale];
}];

for (NSString *s in sorted) { NSLog(@"%@", s); }

output:
as br ol st år ög ös