invasivecode:


Map Kit in iOS 7
iOS 7 has brought a fresh new look to the entire UI, affecting also the Maps and the Map view. Let’s see what those changes are and how to take advantage of them.
If you check the Maps app, you will notice a slight update in the cartography of the map and hybrid mode. This update aims to deliver clearer cartographic information, so some graphic elements (the roads, for example) are blended to the map and labeling stands our more. Pins, callouts and user location views have been updated to embrace the new iOS 7 UI too. There is also the new tintColor property, which applied to MKMapView will affect down all the elements to show callouts and location views with matching colors.
Read More

invasivecode:

Map Kit in iOS 7

iOS 7 has brought a fresh new look to the entire UI, affecting also the Maps and the Map view. Let’s see what those changes are and how to take advantage of them.

If you check the Maps app, you will notice a slight update in the cartography of the map and hybrid mode. This update aims to deliver clearer cartographic information, so some graphic elements (the roads, for example) are blended to the map and labeling stands our more. Pins, callouts and user location views have been updated to embrace the new iOS 7 UI too. There is also the new tintColor property, which applied to MKMapView will affect down all the elements to show callouts and location views with matching colors.

Read More

iOS7: CIFilter to UIImage

Core Image is an image processing and analysis technology designed to provide near real-time processing for still and video images.”

"The CIFilter class produces a CIImage object as output. Typically, a filter takes one or more images as input. 

CIFilter object are set and retrieved through the use of key-value pairs.
If you app is multithreaded, each thread must create its own CIFilter object. Otherwise, your app could behave unexpectedly”.

So, apply a CIFilter to a image is really easy. You can create a chain of filters too.

With iOS7 there are more new filters that you can use in a image.
See the list below:

filters = @[
                @"Original",
                @"CILinearToSRGBToneCurve",
                @"CIPhotoEffectChrome",
                @"CIPhotoEffectFade",
                @"CIPhotoEffectInstant",
                @"CIPhotoEffectMono",
                @"CIPhotoEffectNoir",
                @"CIPhotoEffectProcess",
                @"CIPhotoEffectTonal",
                @"CIPhotoEffectTransfer",
                @"CISRGBToneCurveToLinear",
                @"CIVignetteEffect",
                ];

Then, you can apply a filter to a UIImage using the code below. 
The originalImage is the original UIImage object; the self.imgView.image is the final UIImage.
Setting the chain boolean at true will apply the new filter to a already filtered image.

    if(index == 0)
    {
        self.imgView.image = originalImage;
        return;
    }
    
    NSString *titleFilter = filters[index];
    
    CIImage *ciimage = [[CIImage alloc] initWithImage:chain ? self.imgView.image : originalImage];
    CIFilter *filter = [CIFilter filterWithName:titleFilter keysAndValues:kCIInputImageKey, ciimage, nil]; //Creates a CIFilter object for a specific kind of filter and initializes the input values.
    [filter setDefaults]; //reset filter to default values
    
    CIContext *context = [CIContext contextWithOptions:nil];
    CIImage *output = [filter outputImage]; //apply filter and return a CIImage
    CGImageRef cgimage = [context createCGImage:output fromRect:[output extent]];
    
    self.imgView.image = [UIImage imageWithCGImage:cgimage scale:0 orientation:[self.imgView.image imageOrientation]];
    CGImageRelease(cgimage);

SWIFT: Extensions like Categories

In Objective-C you can add methods to a class, categorizing a class with Categories.

In SWIFT there are not categories… but Extensions. A SWIFT Extensions, that is not like a Objective-C extension, helps you to expand the behavior of existing classes, structures, and enumerations, including those defined in Objective-C.

So, you can extend your class, structure or enumeration, adding functions and protocols conformance.
Moreover, you can add class and static properties (var), that must be computed with get and/or set. Is not possible to add stored properties to classes, structures, or enumerations. 

//ExtendedProtocol
protocol ExtendedProtocol
{
    //write protocol here!
}

//extension
extension String : ExtendedProtocol
{
    var momLove: String { get { return "❤️❤️" } }
    
    func helloMom()
    {
        println("Hello Mom, I Love You! \(momLove)");
    }
}

//test
var test: String = String()
test.helloMom()

Don’t forget that override methods or properties on Objective-C types, is not permitted!

SWIFT vs Objective-C - Lesson basic

Swift is an innovative new programming language for Cocoa and Cocoa Touch. Writing code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next iOS and OS X project — or for addition into your current app — because Swift code works side-by-side with Objective-C.

Below you can obtain the similar results using Objective-C or the new programming language Swift.

Objective-C

@protocol AProtocol 
-(BOOL)methodInProtocol:(NSString *)param1 withParam2:(int)param2;
@end


const NSString *cString = @"Hello!";

NSMutableString *string = [[NSMutableString alloc] initWithFormat:@"Hello"];
[string appendString:@" world"];
NSLog(@"%@", string);
    
int one = 1;
NSLog(@"One value: %i! Amazing!", one);   
    
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Hello", @1, nil];
[array addObject:@YES];
NSLog(@"%@", array);

//emoticons ?!?!?!?!

Swift

protocol AProtocol
{
     func methodInProtocol(param1: String!, withParam2 param2: Int!) -> Bool
}
    
    
let cString: String = "Hello"

var string: String = "Hello"
string = string + " world"; //the ; is optional for more instructions in a single line
println(string)
        
var one = 1
println("One value: \(one)! Amazing!")

var array: Array = ["Hello", 1]
array += true
println(array)

let 🐶🐮 = "adogandacow"
println(🐶🐮)