Monday, 9 November 2015

Array elements Sorting

NSArray *stringsArray = [NSArray arrayWithObjects:
                                 @"string 1",
                                 @"String 21",
                                 @"string 12",
                                 @"String 11",
                                 @"String 02", nil];

static NSStringCompareOptions comparisonOptions = NSCaseInsensitiveSearch | NSNumericSearch |
        NSWidthInsensitiveSearch | NSForcedOrderingSearch;
NSLocale *currentLocale = [NSLocale currentLocale];

NSComparator finderSortBlock = ^(id string1, id string2) {

    NSRange string1Range = NSMakeRange(0, [string1 length]);
    return [string1 compare:string2 options:comparisonOptions range:string1Range locale:currentLocale];
};

NSArray *finderSortArray = [stringsArray sortedArrayUsingComparator:finderSortBlock];
NSLog(@"finderSortArray: %@", finderSortArray);

SOLID Pribciples


SOLID Principles:



SOLID are five basic principles whichhelp to create good software architecture. SOLID is an acronym where:-
  • S stands for SRP (Single responsibility principle )
  • O stands for OCP (Open closed principle)
  • L stands for LSP (Liskov substitution principle)
  • I stands for ISP ( Interface segregation principle)
  • D stands for DIP ( Dependency inversion principle)


SRP
A class should have only a single responsibility. Only one potential change in the software's specification should be able to affect the specification of the class. 

OCP

Software should be open for extension, but closed for modification. 

LSP
Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program 

 ISP
No client should be forced to depend on methods it does not use.
Many client-specific interfaces are better than one general-purpose interface.

 DIP
High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions.

iOS Application iCons sizes