SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Downloaden Sie, um offline zu lesen
Modern Objective-C
    Giuseppe Arici


     Pragma Night @ Talent Garden
It’s All About ...

Syntactic Sugar


                       Pragma Night
Unordered Method
  Declarations

               Pragma Night
Public & Private Method Ordering

  @interface SongPlayer : NSObject
  - (void)playSong:(Song *)song;

  @end

  @implementation SongPlayer
  - (void)playSong:(Song *)song {
      NSError *error;
      [self startAudio:&error];
      /* ... */
  }

 - (void)startAudio:(NSError **)error { /* ... */ }
 Warning:
 @end
 instance method '-startAudio:' not found (return type defaults to 'id')

                                                                   Pragma Night
Wrong Workaround
In the public interface

 @interface SongPlayer : NSObject
 - (void)playSong:(Song *)song;
 - (void)startAudio:(NSError **)error;
 @end

 @implementation SongPlayer
 - (void)playSong:(Song *)song {
     NSError *error;
     [self startAudio:&error];
     /* ... */
 }

 - (void)startAudio:(NSError **)error { /* ... */ }
 @end



                                                      Pragma Night
Okay Workaround 1
In a class extension

 @interface SongPlayer ()

 - (void)startAudio:(NSError **)error;
 @end

 @implementation SongPlayer
 - (void)playSong:(Song *)song {
     NSError *error;
     [self startAudio:&error];
     /* ... */
 }

 - (void)startAudio:(NSError **)error { /* ... */ }
 @end



                                                      Pragma Night
Okay Workaround 2
Reorder methods

 @interface SongPlayer : NSObject
 - (void)playSong:(Song *)song;

 @end

 @implementation SongPlayer
 - (void)startAudio:(NSError **)error { /* ... */ }
 - (void)playSong:(Song *)song {
     NSError *error;
     [self startAudio:&error];
     /* ... */
 }

 @end



                                                      Pragma Night
Best Solution
Parse the @implementation declarations then bodies

 @interface SongPlayer : NSObject
 - (void)playSong:(Song *)song;

 @end

 @implementation SongPlayer
 - (void)playSong:(Song *)song {
     NSError *error;
     [self startAudio:&error];                  Xcode 4.4+
     /* ... */
 }

 - (void)startAudio:(NSError **)error { /* ... */ }
 @end



                                                      Pragma Night
Enum with Fixed
Underlying Type

                  Pragma Night
Enum with Indeterminate Type
Before OS X v10.5 and iOS
 typedef enum {
     NSNumberFormatterNoStyle,
     NSNumberFormatterDecimalStyle,
     NSNumberFormatterCurrencyStyle,
     NSNumberFormatterPercentStyle,
     NSNumberFormatterScientificStyle,
     NSNumberFormatterSpellOutStyle
 } NSNumberFormatterStyle;

 //typedef int NSNumberFormatterStyle;




                                         Pragma Night
Enum with Explicit Type
After OS X v10.5 and iOS
 enum {
     NSNumberFormatterNoStyle,
     NSNumberFormatterDecimalStyle,
     NSNumberFormatterCurrencyStyle,
     NSNumberFormatterPercentStyle,
     NSNumberFormatterScientificStyle,
     NSNumberFormatterSpellOutStyle
 };

 typedef NSUInteger NSNumberFormatterStyle;


 •   Pro: 32-bit and 64-bit portability

 •   Con: no formal relationship between type and enum constants

                                                             Pragma Night
Enum with Fixed Underlying Type
LLVM 4.2+ Compiler
 typedef enum NSNumberFormatterStyle : NSUInteger {
     NSNumberFormatterNoStyle,
     NSNumberFormatterDecimalStyle,
     NSNumberFormatterCurrencyStyle,
     NSNumberFormatterPercentStyle,
     NSNumberFormatterScientificStyle,
     NSNumberFormatterSpellOutStyle
 } NSNumberFormatterStyle;
                                                Xcode 4.4+

 •   Stronger type checking

 •   Better code completion

                                                      Pragma Night
Enum with Fixed Underlying Type
NS_ENUM macro
 typedef NS_ENUM(NSUInteger, NSNumberFormatterStyle) {
     NSNumberFormatterNoStyle,
     NSNumberFormatterDecimalStyle,
     NSNumberFormatterCurrencyStyle,
     NSNumberFormatterPercentStyle,
     NSNumberFormatterScientificStyle,
     NSNumberFormatterSpellOutStyle
 };
                                                Xcode 4.4+

 •   Foundation declares like this



                                                         Pragma Night
Enum with Fixed Underlying Type
Stronger type checking (-Wenum-conversion)


 NSNumberFormatterStyle style = NSNumberFormatterRoundUp; // 3




warning:
implicit conversion from enumeration type 'enum
NSNumberFormatterRoundingMode' to different enumeration type
'NSNumberFormatterStyle' (aka 'enum NSNumberFormatterStyle')

                                                         Pragma Night
Enum with Fixed Underlying Type
Handling all enum values (-Wswitch)
 - (void) printStyle:(NSNumberFormatterStyle) style{
     switch (style) {
         case NSNumberFormatterNoStyle:
             break;
         case NSNumberFormatterSpellOutStyle:
             break;
     }
 }


warning:
4 enumeration values not handled in switch:
'NSNumberFormatterDecimalStyle',
'NSNumberFormatterCurrencyStyle',
'NSNumberFormatterPercentStyle'...
                                                       Pragma Night
@Synthesize by
   Default

                 Pragma Night
Properties Simplify Classes
@interface instance variables

 @interface Person : NSObject {
     NSString *_name;
 }
 @property(strong) NSString *name;
 @end

 @implementation Person




 @synthesize name = _name;

 @end



                                     Pragma Night
Properties Simplify Classes
@implementation instance variables

 @interface Person : NSObject


 @property(strong) NSString *name;
 @end

 @implementation Person {
     NSString *_name;
 }


 @synthesize name = _name;

 @end



                                     Pragma Night
Properties Simplify Classes
Synthesized instance variables

 @interface Person : NSObject


 @property(strong) NSString *name;
 @end

 @implementation Person




 @synthesize name = _name;

 @end



                                     Pragma Night
@Synthesize by Default
LLVM 4.2+ Compiler

 @interface Person : NSObject


 @property(strong) NSString *name;
 @end

 @implementation Person
                                     Xcode 4.4+


 @end



                                           Pragma Night
Instance Variable Name !?
Instance variables now prefixed with “_”

 @interface Person : NSObject


 @property(strong) NSString *name;
 @end

 @implementation Person
 - (NSString *)description {
     return _name;                              Xcode 4.4+
 }
 /* as if you'd written: @synthesize name = _name; */


 @end



                                                        Pragma Night
Backward Compatibility !?
Be careful, when in doubt be fully explicit

 @interface Person : NSObject


 @property(strong) NSString *name;
 @end

 @implementation Person




 @synthesize name;
 /* as if you'd written: @synthesize name = name; */
 @end



                                                       Pragma Night
To        @Synthesize by Default
• Warning: @Synthesize by Default will not
  synthesize a property declared in a protocol
• If you use custom instance variable naming
  convention, enable this warning
  ( -Wobjc-missing-property-synthesis )




                                                 Pragma Night
Core Data NSManagedObject
Opts out of synthesize by default
 /* NSManagedObject.h */

 NS_REQUIRES_PROPERTY_DEFINITIONS
 @interface NSManagedObject : NSObject {



 •   NSManagedObject synthesizes properties

 •   Continue to use @property to declare typed accessors

 •   Continue to use @dynamic to inhibit warnings




                                                            Pragma Night
NSNumbers Literals


                 Pragma Night
NSNumber Creation

NSNumber *value;

value = [NSNumber numberWithChar:'X'];

value = [NSNumber numberWithInt:42];

value = [NSNumber numberWithUnsignedLong:42ul];

value = [NSNumber numberWithLongLong:42ll];

value = [NSNumber numberWithFloat:0.42f];

value = [NSNumber numberWithDouble:0.42];

value = [NSNumber numberWithBool:YES];




                                                  Pragma Night
NSNumber Creation

NSNumber *value;

value = @'X';

value = @42;

value = @42ul;

value = @42ll;

value = @0.42f;
                        Xcode 4.4+
value = @0.42;

value = @YES;




                              Pragma Night
Backward Compatibility !?
#define YES      (BOOL)1     // Before iOS 6, OSX 10.8


#define YES      ((BOOL)1) // After iOS 6, OSX 10.8


Workarounds
@(YES)                       // Use parentheses around BOOL Macros


#if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000
#if __has_feature(objc_bool)
#undef YES
#undef NO                       // Redefine   BOOL Macros
#define YES __objc_yes
#define NO __objc_no
#endif
#endif



                                                             Pragma Night
Boxed Expression
    Literals

                   Pragma Night
Boxed Expression Literals

NSNumber *orientation =
    [NSNumber numberWithInt:UIDeviceOrientationPortrait];

NSNumber *piOverSixteen =
    [NSNumber numberWithDouble:( M_PI / 16 )];

NSNumber *parityDigit =
    [NSNumber numberWithChar:"EO"[i % 2]];

NSString *path =
    [NSString stringWithUTF8String:getenv("PATH")];

NSNumber *usesCompass =
    [NSNumber numberWithBool:
        [CLLocationManager headingAvailable]];




                                                        Pragma Night
Boxed Expression Literals

NSNumber *orientation =
    @( UIDeviceOrientationPortrait );

NSNumber *piOverSixteen =
    @( M_PI / 16 );

NSNumber *parityDigit =
    @( "OE"[i % 2] );

NSString *path =
    @( getenv("PATH") );
                                                 Xcode 4.4+
NSNumber *usesCompass =
    @( [CLLocationManager headingAvailable] );




                                                       Pragma Night
Array Literals


                 Pragma Night
Array Creation
More choices, and more chances for errors


 NSArray *array;

 array = [NSArray array];

 array = [NSArray arrayWithObject:a];

 array = [NSArray arrayWithObjects:a, b, c, nil];

 id objects[] = { a, b, c };
 NSUInteger count = sizeof(objects) / sizeof(id);
 array = [NSArray arrayWithObjects:objects count:count];




                                                           Pragma Night
Nil Termination
Inconsistent behavior
 // if you write:
 id a = nil, b = @"hello", c = @42;
 NSArray *array
     = [NSArray arrayWithObjects:a, b, c, nil];

Array will be empty

 // if you write:
 id objects[] = { nil, @"hello", @42 };
 NSUInteger count = sizeof(objects)/ sizeof(id);
 NSArray *array
     = [NSArray arrayWithObjects:objects count:count];


Exception: attempt to insert nil object from objects[0]

                                                          Pragma Night
Array Creation

NSArray *array;

array = [NSArray array];

array = [NSArray arrayWithObject:a];

array = [NSArray arrayWithObjects:a, b, c, nil];

id objects[] = { a, b, c };
NSUInteger count = sizeof(objects) / sizeof(id);
array = [NSArray arrayWithObjects:objects count:count];




                                                          Pragma Night
Array Creation

NSArray *array;

array = @[];

array = @[ a ];

array = @[ a, b, c ];
                                   Xcode 4.4+
array = @[ a, b, c ];




                                         Pragma Night
How Array Literals Work
// when you write this:

NSArray *array = @[ a, b, c ];




// compiler generates:

id objects[] = { a, b, c };
NSUInteger count = sizeof(objects)/ sizeof(id);
NSArray *array
    = [NSArray arrayWithObjects:objects count:count];




                                                        Pragma Night
Dictionary Literals


                      Pragma Night
Dictionary Creation
More choices, and more chances for errors

 NSDictionary *dict;

 dict = [NSDictionary dictionary];

 dict = [NSDictionary dictionaryWithObject:o1 forKey:k1];

 dict = [NSDictionary dictionaryWithObjectsAndKeys:
     o1, k1, o2, k2, o3, k3, nil];

 id objects[] = { o1, o2, o3 };
 id keys[] = { k1, k2, k3 };
 NSUInteger count = sizeof(objects) / sizeof(id);
 dict = [NSDictionary dictionaryWithObjects:objects
                                    forKeys:keys
                                      count:count];


                                                            Pragma Night
Dictionary Creation

NSDictionary *dict;

dict = [NSDictionary dictionary];

dict = [NSDictionary dictionaryWithObject:o1 forKey:k1];

dict = [NSDictionary dictionaryWithObjectsAndKeys:
    o1, k1, o2, k2, o3, k3, nil];

id objects[] = { o1, o2, o3 };
id keys[] = { k1, k2, k3 };
NSUInteger count = sizeof(objects) / sizeof(id);
dict = [NSDictionary dictionaryWithObjects:objects
                                   forKeys:keys
                                     count:count];




                                                           Pragma Night
Dictionary Creation

NSDictionary *dict;

dict = @{};

dict = @{ k1 : o1 }; // key before object

dict = @{ k1 : o1, k2 : o2, k3 : o3 };



                                            Xcode 4.4+
dict = @{ k1 : o1, k2 : o2, k3 : o3 };




                                                  Pragma Night
How Dictionary Literals Work
// when you write this:

NSDictionary *dict = @{ k1 : o1, k2 : o2, k3 : o3 };




// compiler generates:

id objects[] = { o1, o2, o3 };
id keys[] = { k1, k2, k3 };
NSUInteger count = sizeof(objects) / sizeof(id);
NSDictionary *dict =
    [NSDictionary dictionaryWithObjects:objects
                                 orKeys:keys
                                  count:count];




                                                       Pragma Night
Container Literals Restriction
All containers are immutable, mutable use: -mutableCopy
   NSMutableArray *mutablePragmers =
   [@[ @"Fra", @"Giu", @"Mat", @"Max", @"Ste" ] mutableCopy];



For constant containers, simply implement +initialize
 static NSArray *thePragmers;

 + (void)initialize {
     if (self == [MyClass class]) {
         thePragmers =
             @[ @"Fra", @"Giu", @"Mat", @"Max", @"Ste" ];
     }
 }


                                                            Pragma Night
Object Subscripting


                  Pragma Night
Array Subscripting
New syntax to access object at index: nsarray[index]

 @implementation SongList
 {
     NSMutableArray *_songs;
 }

 - (Song *)replaceSong:(Song *)newSong
                atIndex:(NSUInteger)idx
 {
     Song *oldSong = [_songs objectAtIndex:idx];
      [_songs replaceObjectAtIndex:idx withObject:newSong];
     return oldSong;
 }
 @end



                                                          Pragma Night
Array Subscripting
New syntax to access object at index: nsarray[index]

 @implementation SongList
 {
     NSMutableArray *_songs;
 }

 - (Song *)replaceSong:(Song *)newSong
               atIndex:(NSUInteger)idx
 {                                       Xcode 4.4+
     Song *oldSong = _songs[idx];
     _songs[idx] = newSong;
     return oldSong;
 }
 @end



                                                Pragma Night
Dictionary Subscripting
New syntax to access object by key: nsdictionary[key]

 @implementation Database
 {
     NSMutableDictionary *_storage;
 }

 - (id)replaceObject:(id)newObject
               forKey:(id <NSCopying>)key
 {
     id oldObject = [_storage objectForKey:key];
      [_storage setObject:newObject forKey:key];
     return oldObject;
 }
 @end



                                                   Pragma Night
Dictionary Subscripting
New syntax to access object by key: nsdictionary[key]

 @implementation Database
 {
     NSMutableDictionary *_storage;
 }

 - (id)replaceObject:(id)newObject
              forKey:(id <NSCopying>)key
 {                                         Xcode 4.4+
     id oldObject = _storage[key];
     _storage[key] = newObject;
     return oldObject;
 }
 @end



                                                 Pragma Night
How Subscripting Works
                                                              iOS 6
Array Style: Indexed subscripting methods                    OSX 10.8

 - (elementType)objectAtIndexedSubscript:(indexType)idx

 - (void)setObject:(elementType)obj
 atIndexedSubscript:(indexType)idx;

elementType must be an object pointer, indexType must be integral

                                                              iOS 6
Dictionary Style: Keyed subscripting methods                 OSX 10.8


 - (elementType)objectForKeyedSubscript:(keyType)key;

 - (void)setObject:(elementType)obj
 forKeyedSubscript:(keyType)key;

elementType and keyType must be an object pointer
                                                              Pragma Night
Indexed Subscripting
setObject:atIndexedSubscript:

 @implementation SongList
 {
     NSMutableArray *_songs;
 }

 - (Song *)replaceSong:(Song *)newSong
               atIndex:(NSUInteger)idx
 {
     Song *oldSong = _songs[idx];
     _songs[idx] = newSong;
     return oldSong;
 }
 @end



                                         Pragma Night
Indexed Subscripting
setObject:atIndexedSubscript:

 @implementation SongList
 {
     NSMutableArray *_songs;
 }

 - (Song *)replaceSong:(Song *)newSong
               atIndex:(NSUInteger)idx
 {
     Song *oldSong = _songs[idx];
     [_songs setObject:newSong atIndexedSubscript:idx];
     return oldSong;
 }
 @end



                                                          Pragma Night
Keyed Subscripting
setObject:atIndexedSubscript:

 @implementation Database
 {
     NSMutableDictionary *_storage;
 }

 - (id)replaceObject:(id)newObject
              forKey:(id <NSCopying>)key
 {
     id oldObject = _storage[key];
     _storage[key] = newObject;
     return oldObject;
 }
 @end



                                           Pragma Night
Keyed Subscripting
setObject:atIndexedSubscript:

 @implementation Database
 {
     NSMutableDictionary *_storage;
 }

 - (id)replaceObject:(id)newObject
              forKey:(id <NSCopying>)key
 {
     id oldObject = _storage[key];
     [_storage setObject:newObject forKey:key];
     return oldObject;
 }
 @end



                                                  Pragma Night
Backward Compatibility !?
To deploy back to iOS 5 and iOS 4 you need ARCLite:
use ARC or set explicit linker flag: “-fobjc-arc”

To make compiler happy, you should add 4 categories:
 #if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000
 @interface NSDictionary(BCSubscripting)
 - (id)objectForKeyedSubscript:(id)key;
 @end

 @interface NSMutableDictionary(BCSubscripting)
 - (void)setObject:(id)obj forKeyedSubscript:(id )key;
 @end

 @interface NSArray(BCSubscripting)
 - (id)objectAtIndexedSubscript:(NSUInteger)idx;
 @end

 @interface NSMutableArray(BCSubscripting)
 - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
 @end
 #endif



                                                                 Pragma Night
Your Classes Can Be Subscriptable
 @interface SongList : NSObject
 - (Song *)objectAtIndexedSubscript:(NSUInteger)idx;
 - (void)      setObject:(Song *)song
      atIndexedSubscript:(NSUInteger)idx;
 @end

 @implementation SongList {
     NSMutableArray *_songs;
 }
 - (Song *)objectAtIndexedSubscript:(NSUInteger)idx {
     return (Song *)_songs[idx];
 }
 - (void)      setObject:(Song *)song
      atIndexedSubscript:(NSUInteger)idx {
     _songs[idx] = song;
 }
 @end



                                                        Pragma Night
Summary


          Pragma Night
Availability
                        Feature     Xcode 4.4+   iOS 6 OSX 10.8
 Unordered Method Declarations          ✓
Enum With Fixed Underlying Type         ✓
         @Synthesize by Default         ✓
            NSNumbers Literals          ✓
       Boxed Expression Literals        ✓
                   Array Literals       ✓
              Dictionary Literals       ✓
             Object Subscripting        ✓              ✓*

                     * Partially Required
                                                         Pragma Night
Migration
Apple provides a migration tool which is build into
Xcode: Edit Refactor Convert to Modern ...




                                                 Pragma Night
Demo


       Pragma Night
Modern Objective-C References


•   Clang: Objective-C Literals

•   Apple: Programming with Objective-C

•   WWDC 2012 – Session 405 – Modern Objective-C

•   Mike Ash: Friday Q&A 2012-06-22: Objective-C Literals




                                                            Pragma Night
Modern Objective-C Books




                       Pragma Night
NSLog(@”Thank you!”);




  giuseppe.arici@pragmamark.org

                                  Pragma Night

Weitere ähnliche Inhalte

Was ist angesagt?

Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Peter Maas
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Nilesh Jayanandana
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchMatteo Battaglio
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6Solution4Future
 
Know yourengines velocity2011
Know yourengines velocity2011Know yourengines velocity2011
Know yourengines velocity2011Demis Bellot
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overviewhesher
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisRuslan Shevchenko
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMCharles Nutter
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMTom Lee
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An IntroductionManvendra Singh
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012rivierarb
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Feihong Hsu
 
Combining the strength of erlang and Ruby
Combining the strength of erlang and RubyCombining the strength of erlang and Ruby
Combining the strength of erlang and RubyMartin Rehfeld
 
Command Line Applications in Ruby, 2018-05-08
Command Line Applications in Ruby, 2018-05-08Command Line Applications in Ruby, 2018-05-08
Command Line Applications in Ruby, 2018-05-08Keith Bennett
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracerrahulrevo
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesCharles Nutter
 

Was ist angesagt? (20)

Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3Domain Specific Languages In Scala Duse3
Domain Specific Languages In Scala Duse3
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
 
Dispatch in Clojure
Dispatch in ClojureDispatch in Clojure
Dispatch in Clojure
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
 
Know yourengines velocity2011
Know yourengines velocity2011Know yourengines velocity2011
Know yourengines velocity2011
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVM
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVM
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Asynchronous I/O in Python 3
Asynchronous I/O in Python 3Asynchronous I/O in Python 3
Asynchronous I/O in Python 3
 
Combining the strength of erlang and Ruby
Combining the strength of erlang and RubyCombining the strength of erlang and Ruby
Combining the strength of erlang and Ruby
 
Command Line Applications in Ruby, 2018-05-08
Command Line Applications in Ruby, 2018-05-08Command Line Applications in Ruby, 2018-05-08
Command Line Applications in Ruby, 2018-05-08
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracer
 
At Scale With Style
At Scale With StyleAt Scale With Style
At Scale With Style
 
RubyMotion Introduction
RubyMotion IntroductionRubyMotion Introduction
RubyMotion Introduction
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 

Andere mochten auch

iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...Ahmed Ali
 
Thinking in swift ppt
Thinking in swift pptThinking in swift ppt
Thinking in swift pptKeith Moon
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) Jonathan Engelsma
 
iOS NSAgora #3: Objective-C vs. Swift
iOS NSAgora #3: Objective-C vs. SwiftiOS NSAgora #3: Objective-C vs. Swift
iOS NSAgora #3: Objective-C vs. SwiftAlex Cristea
 
Spring MVC to iOS and the REST
Spring MVC to iOS and the RESTSpring MVC to iOS and the REST
Spring MVC to iOS and the RESTRoy Clarkson
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, SwiftYandex
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & ArchitectureMassimo Oliviero
 
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSSoftware architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSJinkyu Kim
 
Workshop iOS 2: Swift - Structures
Workshop iOS 2: Swift - StructuresWorkshop iOS 2: Swift - Structures
Workshop iOS 2: Swift - StructuresVisual Engineering
 
Ports & sockets
Ports  & sockets Ports  & sockets
Ports & sockets myrajendra
 
Writing Your App Swiftly
Writing Your App SwiftlyWriting Your App Swiftly
Writing Your App SwiftlySommer Panage
 

Andere mochten auch (16)

Architecting iOS Project
Architecting iOS ProjectArchitecting iOS Project
Architecting iOS Project
 
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...
 
Ios - Intorduction to view controller
Ios - Intorduction to view controllerIos - Intorduction to view controller
Ios - Intorduction to view controller
 
Thinking in swift ppt
Thinking in swift pptThinking in swift ppt
Thinking in swift ppt
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
 
iOS (7) Workshop
iOS (7) WorkshopiOS (7) Workshop
iOS (7) Workshop
 
iOS NSAgora #3: Objective-C vs. Swift
iOS NSAgora #3: Objective-C vs. SwiftiOS NSAgora #3: Objective-C vs. Swift
iOS NSAgora #3: Objective-C vs. Swift
 
iOS: Table Views
iOS: Table ViewsiOS: Table Views
iOS: Table Views
 
Spring MVC to iOS and the REST
Spring MVC to iOS and the RESTSpring MVC to iOS and the REST
Spring MVC to iOS and the REST
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, Swift
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & Architecture
 
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOSSoftware architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
 
Workshop iOS 2: Swift - Structures
Workshop iOS 2: Swift - StructuresWorkshop iOS 2: Swift - Structures
Workshop iOS 2: Swift - Structures
 
Ports & sockets
Ports  & sockets Ports  & sockets
Ports & sockets
 
Apple iOS
Apple iOSApple iOS
Apple iOS
 
Writing Your App Swiftly
Writing Your App SwiftlyWriting Your App Swiftly
Writing Your App Swiftly
 

Ähnlich wie Modern Objective-C @ Pragma Night

JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesSiarhei Barysiuk
 
Modernize your Objective-C
Modernize your Objective-CModernize your Objective-C
Modernize your Objective-CMassimo Oliviero
 
Blocks and GCD(Grand Central Dispatch)
Blocks and GCD(Grand Central Dispatch)Blocks and GCD(Grand Central Dispatch)
Blocks and GCD(Grand Central Dispatch)Jigar Maheshwari
 
Regular Expression (RegExp)
Regular Expression (RegExp)Regular Expression (RegExp)
Regular Expression (RegExp)Davide Dell'Erba
 
Cross platform Objective-C Strategy
Cross platform Objective-C StrategyCross platform Objective-C Strategy
Cross platform Objective-C StrategyGraham Lee
 
AST Transformations
AST TransformationsAST Transformations
AST TransformationsHamletDRC
 
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfQ1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfabdulrahamanbags
 
TLPI - 6 Process
TLPI - 6 ProcessTLPI - 6 Process
TLPI - 6 ProcessShu-Yu Fu
 
please help me with this and explain in details also in the first qu.pdf
please help me with this and explain in details also in the first qu.pdfplease help me with this and explain in details also in the first qu.pdf
please help me with this and explain in details also in the first qu.pdfnewfaransportsfitnes
 
Tamarin and ECMAScript 4
Tamarin and ECMAScript 4Tamarin and ECMAScript 4
Tamarin and ECMAScript 4jeresig
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdfarshiartpalace
 
Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4elliando dias
 
Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법Jung Kim
 
Ast transformations
Ast transformationsAst transformations
Ast transformationsHamletDRC
 
JCConf 2021 - Java17: The Next LTS
JCConf 2021 - Java17: The Next LTSJCConf 2021 - Java17: The Next LTS
JCConf 2021 - Java17: The Next LTSJoseph Kuo
 
Unit 4
Unit 4Unit 4
Unit 4siddr
 
Promise of an API
Promise of an APIPromise of an API
Promise of an APIMaxim Zaks
 

Ähnlich wie Modern Objective-C @ Pragma Night (20)

JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 
Modernize your Objective-C
Modernize your Objective-CModernize your Objective-C
Modernize your Objective-C
 
Blocks and GCD(Grand Central Dispatch)
Blocks and GCD(Grand Central Dispatch)Blocks and GCD(Grand Central Dispatch)
Blocks and GCD(Grand Central Dispatch)
 
Regular Expression (RegExp)
Regular Expression (RegExp)Regular Expression (RegExp)
Regular Expression (RegExp)
 
Cross platform Objective-C Strategy
Cross platform Objective-C StrategyCross platform Objective-C Strategy
Cross platform Objective-C Strategy
 
AST Transformations
AST TransformationsAST Transformations
AST Transformations
 
Scheming Defaults
Scheming DefaultsScheming Defaults
Scheming Defaults
 
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfQ1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
 
TLPI - 6 Process
TLPI - 6 ProcessTLPI - 6 Process
TLPI - 6 Process
 
please help me with this and explain in details also in the first qu.pdf
please help me with this and explain in details also in the first qu.pdfplease help me with this and explain in details also in the first qu.pdf
please help me with this and explain in details also in the first qu.pdf
 
Rustlabs Quick Start
Rustlabs Quick StartRustlabs Quick Start
Rustlabs Quick Start
 
Tamarin and ECMAScript 4
Tamarin and ECMAScript 4Tamarin and ECMAScript 4
Tamarin and ECMAScript 4
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
 
front-end dev
front-end devfront-end dev
front-end dev
 
Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4
 
Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
JCConf 2021 - Java17: The Next LTS
JCConf 2021 - Java17: The Next LTSJCConf 2021 - Java17: The Next LTS
JCConf 2021 - Java17: The Next LTS
 
Unit 4
Unit 4Unit 4
Unit 4
 
Promise of an API
Promise of an APIPromise of an API
Promise of an API
 

Mehr von Giuseppe Arici

Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming LanguageGiuseppe Arici
 
Auto Layout Under Control @ Pragma conference 2013
Auto Layout Under Control @ Pragma conference 2013Auto Layout Under Control @ Pragma conference 2013
Auto Layout Under Control @ Pragma conference 2013Giuseppe Arici
 
Automatic Reference Counting
Automatic Reference CountingAutomatic Reference Counting
Automatic Reference CountingGiuseppe Arici
 

Mehr von Giuseppe Arici (8)

Digital Universitas
Digital UniversitasDigital Universitas
Digital Universitas
 
Swift Introduction
Swift IntroductionSwift Introduction
Swift Introduction
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
Auto Layout Under Control @ Pragma conference 2013
Auto Layout Under Control @ Pragma conference 2013Auto Layout Under Control @ Pragma conference 2013
Auto Layout Under Control @ Pragma conference 2013
 
GDB Mobile
GDB MobileGDB Mobile
GDB Mobile
 
Objective-C @ ITIS
Objective-C @ ITISObjective-C @ ITIS
Objective-C @ ITIS
 
Objective-C
Objective-CObjective-C
Objective-C
 
Automatic Reference Counting
Automatic Reference CountingAutomatic Reference Counting
Automatic Reference Counting
 

Kürzlich hochgeladen

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Kürzlich hochgeladen (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Modern Objective-C @ Pragma Night

  • 1. Modern Objective-C Giuseppe Arici Pragma Night @ Talent Garden
  • 2. It’s All About ... Syntactic Sugar Pragma Night
  • 3. Unordered Method Declarations Pragma Night
  • 4. Public & Private Method Ordering @interface SongPlayer : NSObject - (void)playSong:(Song *)song; @end @implementation SongPlayer - (void)playSong:(Song *)song { NSError *error; [self startAudio:&error]; /* ... */ } - (void)startAudio:(NSError **)error { /* ... */ } Warning: @end instance method '-startAudio:' not found (return type defaults to 'id') Pragma Night
  • 5. Wrong Workaround In the public interface @interface SongPlayer : NSObject - (void)playSong:(Song *)song; - (void)startAudio:(NSError **)error; @end @implementation SongPlayer - (void)playSong:(Song *)song { NSError *error; [self startAudio:&error]; /* ... */ } - (void)startAudio:(NSError **)error { /* ... */ } @end Pragma Night
  • 6. Okay Workaround 1 In a class extension @interface SongPlayer () - (void)startAudio:(NSError **)error; @end @implementation SongPlayer - (void)playSong:(Song *)song { NSError *error; [self startAudio:&error]; /* ... */ } - (void)startAudio:(NSError **)error { /* ... */ } @end Pragma Night
  • 7. Okay Workaround 2 Reorder methods @interface SongPlayer : NSObject - (void)playSong:(Song *)song; @end @implementation SongPlayer - (void)startAudio:(NSError **)error { /* ... */ } - (void)playSong:(Song *)song { NSError *error; [self startAudio:&error]; /* ... */ } @end Pragma Night
  • 8. Best Solution Parse the @implementation declarations then bodies @interface SongPlayer : NSObject - (void)playSong:(Song *)song; @end @implementation SongPlayer - (void)playSong:(Song *)song { NSError *error; [self startAudio:&error]; Xcode 4.4+ /* ... */ } - (void)startAudio:(NSError **)error { /* ... */ } @end Pragma Night
  • 9. Enum with Fixed Underlying Type Pragma Night
  • 10. Enum with Indeterminate Type Before OS X v10.5 and iOS typedef enum { NSNumberFormatterNoStyle, NSNumberFormatterDecimalStyle, NSNumberFormatterCurrencyStyle, NSNumberFormatterPercentStyle, NSNumberFormatterScientificStyle, NSNumberFormatterSpellOutStyle } NSNumberFormatterStyle; //typedef int NSNumberFormatterStyle; Pragma Night
  • 11. Enum with Explicit Type After OS X v10.5 and iOS enum { NSNumberFormatterNoStyle, NSNumberFormatterDecimalStyle, NSNumberFormatterCurrencyStyle, NSNumberFormatterPercentStyle, NSNumberFormatterScientificStyle, NSNumberFormatterSpellOutStyle }; typedef NSUInteger NSNumberFormatterStyle; • Pro: 32-bit and 64-bit portability • Con: no formal relationship between type and enum constants Pragma Night
  • 12. Enum with Fixed Underlying Type LLVM 4.2+ Compiler typedef enum NSNumberFormatterStyle : NSUInteger { NSNumberFormatterNoStyle, NSNumberFormatterDecimalStyle, NSNumberFormatterCurrencyStyle, NSNumberFormatterPercentStyle, NSNumberFormatterScientificStyle, NSNumberFormatterSpellOutStyle } NSNumberFormatterStyle; Xcode 4.4+ • Stronger type checking • Better code completion Pragma Night
  • 13. Enum with Fixed Underlying Type NS_ENUM macro typedef NS_ENUM(NSUInteger, NSNumberFormatterStyle) { NSNumberFormatterNoStyle, NSNumberFormatterDecimalStyle, NSNumberFormatterCurrencyStyle, NSNumberFormatterPercentStyle, NSNumberFormatterScientificStyle, NSNumberFormatterSpellOutStyle }; Xcode 4.4+ • Foundation declares like this Pragma Night
  • 14. Enum with Fixed Underlying Type Stronger type checking (-Wenum-conversion) NSNumberFormatterStyle style = NSNumberFormatterRoundUp; // 3 warning: implicit conversion from enumeration type 'enum NSNumberFormatterRoundingMode' to different enumeration type 'NSNumberFormatterStyle' (aka 'enum NSNumberFormatterStyle') Pragma Night
  • 15. Enum with Fixed Underlying Type Handling all enum values (-Wswitch) - (void) printStyle:(NSNumberFormatterStyle) style{ switch (style) { case NSNumberFormatterNoStyle: break; case NSNumberFormatterSpellOutStyle: break; } } warning: 4 enumeration values not handled in switch: 'NSNumberFormatterDecimalStyle', 'NSNumberFormatterCurrencyStyle', 'NSNumberFormatterPercentStyle'... Pragma Night
  • 16. @Synthesize by Default Pragma Night
  • 17. Properties Simplify Classes @interface instance variables @interface Person : NSObject { NSString *_name; } @property(strong) NSString *name; @end @implementation Person @synthesize name = _name; @end Pragma Night
  • 18. Properties Simplify Classes @implementation instance variables @interface Person : NSObject @property(strong) NSString *name; @end @implementation Person { NSString *_name; } @synthesize name = _name; @end Pragma Night
  • 19. Properties Simplify Classes Synthesized instance variables @interface Person : NSObject @property(strong) NSString *name; @end @implementation Person @synthesize name = _name; @end Pragma Night
  • 20. @Synthesize by Default LLVM 4.2+ Compiler @interface Person : NSObject @property(strong) NSString *name; @end @implementation Person Xcode 4.4+ @end Pragma Night
  • 21. Instance Variable Name !? Instance variables now prefixed with “_” @interface Person : NSObject @property(strong) NSString *name; @end @implementation Person - (NSString *)description { return _name; Xcode 4.4+ } /* as if you'd written: @synthesize name = _name; */ @end Pragma Night
  • 22. Backward Compatibility !? Be careful, when in doubt be fully explicit @interface Person : NSObject @property(strong) NSString *name; @end @implementation Person @synthesize name; /* as if you'd written: @synthesize name = name; */ @end Pragma Night
  • 23. To @Synthesize by Default • Warning: @Synthesize by Default will not synthesize a property declared in a protocol • If you use custom instance variable naming convention, enable this warning ( -Wobjc-missing-property-synthesis ) Pragma Night
  • 24. Core Data NSManagedObject Opts out of synthesize by default /* NSManagedObject.h */ NS_REQUIRES_PROPERTY_DEFINITIONS @interface NSManagedObject : NSObject { • NSManagedObject synthesizes properties • Continue to use @property to declare typed accessors • Continue to use @dynamic to inhibit warnings Pragma Night
  • 25. NSNumbers Literals Pragma Night
  • 26. NSNumber Creation NSNumber *value; value = [NSNumber numberWithChar:'X']; value = [NSNumber numberWithInt:42]; value = [NSNumber numberWithUnsignedLong:42ul]; value = [NSNumber numberWithLongLong:42ll]; value = [NSNumber numberWithFloat:0.42f]; value = [NSNumber numberWithDouble:0.42]; value = [NSNumber numberWithBool:YES]; Pragma Night
  • 27. NSNumber Creation NSNumber *value; value = @'X'; value = @42; value = @42ul; value = @42ll; value = @0.42f; Xcode 4.4+ value = @0.42; value = @YES; Pragma Night
  • 28. Backward Compatibility !? #define YES (BOOL)1 // Before iOS 6, OSX 10.8 #define YES ((BOOL)1) // After iOS 6, OSX 10.8 Workarounds @(YES) // Use parentheses around BOOL Macros #if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000 #if __has_feature(objc_bool) #undef YES #undef NO // Redefine BOOL Macros #define YES __objc_yes #define NO __objc_no #endif #endif Pragma Night
  • 29. Boxed Expression Literals Pragma Night
  • 30. Boxed Expression Literals NSNumber *orientation = [NSNumber numberWithInt:UIDeviceOrientationPortrait]; NSNumber *piOverSixteen = [NSNumber numberWithDouble:( M_PI / 16 )]; NSNumber *parityDigit = [NSNumber numberWithChar:"EO"[i % 2]]; NSString *path = [NSString stringWithUTF8String:getenv("PATH")]; NSNumber *usesCompass = [NSNumber numberWithBool: [CLLocationManager headingAvailable]]; Pragma Night
  • 31. Boxed Expression Literals NSNumber *orientation = @( UIDeviceOrientationPortrait ); NSNumber *piOverSixteen = @( M_PI / 16 ); NSNumber *parityDigit = @( "OE"[i % 2] ); NSString *path = @( getenv("PATH") ); Xcode 4.4+ NSNumber *usesCompass = @( [CLLocationManager headingAvailable] ); Pragma Night
  • 32. Array Literals Pragma Night
  • 33. Array Creation More choices, and more chances for errors NSArray *array; array = [NSArray array]; array = [NSArray arrayWithObject:a]; array = [NSArray arrayWithObjects:a, b, c, nil]; id objects[] = { a, b, c }; NSUInteger count = sizeof(objects) / sizeof(id); array = [NSArray arrayWithObjects:objects count:count]; Pragma Night
  • 34. Nil Termination Inconsistent behavior // if you write: id a = nil, b = @"hello", c = @42; NSArray *array = [NSArray arrayWithObjects:a, b, c, nil]; Array will be empty // if you write: id objects[] = { nil, @"hello", @42 }; NSUInteger count = sizeof(objects)/ sizeof(id); NSArray *array = [NSArray arrayWithObjects:objects count:count]; Exception: attempt to insert nil object from objects[0] Pragma Night
  • 35. Array Creation NSArray *array; array = [NSArray array]; array = [NSArray arrayWithObject:a]; array = [NSArray arrayWithObjects:a, b, c, nil]; id objects[] = { a, b, c }; NSUInteger count = sizeof(objects) / sizeof(id); array = [NSArray arrayWithObjects:objects count:count]; Pragma Night
  • 36. Array Creation NSArray *array; array = @[]; array = @[ a ]; array = @[ a, b, c ]; Xcode 4.4+ array = @[ a, b, c ]; Pragma Night
  • 37. How Array Literals Work // when you write this: NSArray *array = @[ a, b, c ]; // compiler generates: id objects[] = { a, b, c }; NSUInteger count = sizeof(objects)/ sizeof(id); NSArray *array = [NSArray arrayWithObjects:objects count:count]; Pragma Night
  • 38. Dictionary Literals Pragma Night
  • 39. Dictionary Creation More choices, and more chances for errors NSDictionary *dict; dict = [NSDictionary dictionary]; dict = [NSDictionary dictionaryWithObject:o1 forKey:k1]; dict = [NSDictionary dictionaryWithObjectsAndKeys: o1, k1, o2, k2, o3, k3, nil]; id objects[] = { o1, o2, o3 }; id keys[] = { k1, k2, k3 }; NSUInteger count = sizeof(objects) / sizeof(id); dict = [NSDictionary dictionaryWithObjects:objects forKeys:keys count:count]; Pragma Night
  • 40. Dictionary Creation NSDictionary *dict; dict = [NSDictionary dictionary]; dict = [NSDictionary dictionaryWithObject:o1 forKey:k1]; dict = [NSDictionary dictionaryWithObjectsAndKeys: o1, k1, o2, k2, o3, k3, nil]; id objects[] = { o1, o2, o3 }; id keys[] = { k1, k2, k3 }; NSUInteger count = sizeof(objects) / sizeof(id); dict = [NSDictionary dictionaryWithObjects:objects forKeys:keys count:count]; Pragma Night
  • 41. Dictionary Creation NSDictionary *dict; dict = @{}; dict = @{ k1 : o1 }; // key before object dict = @{ k1 : o1, k2 : o2, k3 : o3 }; Xcode 4.4+ dict = @{ k1 : o1, k2 : o2, k3 : o3 }; Pragma Night
  • 42. How Dictionary Literals Work // when you write this: NSDictionary *dict = @{ k1 : o1, k2 : o2, k3 : o3 }; // compiler generates: id objects[] = { o1, o2, o3 }; id keys[] = { k1, k2, k3 }; NSUInteger count = sizeof(objects) / sizeof(id); NSDictionary *dict = [NSDictionary dictionaryWithObjects:objects orKeys:keys count:count]; Pragma Night
  • 43. Container Literals Restriction All containers are immutable, mutable use: -mutableCopy NSMutableArray *mutablePragmers = [@[ @"Fra", @"Giu", @"Mat", @"Max", @"Ste" ] mutableCopy]; For constant containers, simply implement +initialize static NSArray *thePragmers; + (void)initialize { if (self == [MyClass class]) { thePragmers = @[ @"Fra", @"Giu", @"Mat", @"Max", @"Ste" ]; } } Pragma Night
  • 44. Object Subscripting Pragma Night
  • 45. Array Subscripting New syntax to access object at index: nsarray[index] @implementation SongList { NSMutableArray *_songs; } - (Song *)replaceSong:(Song *)newSong atIndex:(NSUInteger)idx { Song *oldSong = [_songs objectAtIndex:idx]; [_songs replaceObjectAtIndex:idx withObject:newSong]; return oldSong; } @end Pragma Night
  • 46. Array Subscripting New syntax to access object at index: nsarray[index] @implementation SongList { NSMutableArray *_songs; } - (Song *)replaceSong:(Song *)newSong atIndex:(NSUInteger)idx { Xcode 4.4+ Song *oldSong = _songs[idx]; _songs[idx] = newSong; return oldSong; } @end Pragma Night
  • 47. Dictionary Subscripting New syntax to access object by key: nsdictionary[key] @implementation Database { NSMutableDictionary *_storage; } - (id)replaceObject:(id)newObject forKey:(id <NSCopying>)key { id oldObject = [_storage objectForKey:key]; [_storage setObject:newObject forKey:key]; return oldObject; } @end Pragma Night
  • 48. Dictionary Subscripting New syntax to access object by key: nsdictionary[key] @implementation Database { NSMutableDictionary *_storage; } - (id)replaceObject:(id)newObject forKey:(id <NSCopying>)key { Xcode 4.4+ id oldObject = _storage[key]; _storage[key] = newObject; return oldObject; } @end Pragma Night
  • 49. How Subscripting Works iOS 6 Array Style: Indexed subscripting methods OSX 10.8 - (elementType)objectAtIndexedSubscript:(indexType)idx - (void)setObject:(elementType)obj atIndexedSubscript:(indexType)idx; elementType must be an object pointer, indexType must be integral iOS 6 Dictionary Style: Keyed subscripting methods OSX 10.8 - (elementType)objectForKeyedSubscript:(keyType)key; - (void)setObject:(elementType)obj forKeyedSubscript:(keyType)key; elementType and keyType must be an object pointer Pragma Night
  • 50. Indexed Subscripting setObject:atIndexedSubscript: @implementation SongList { NSMutableArray *_songs; } - (Song *)replaceSong:(Song *)newSong atIndex:(NSUInteger)idx { Song *oldSong = _songs[idx]; _songs[idx] = newSong; return oldSong; } @end Pragma Night
  • 51. Indexed Subscripting setObject:atIndexedSubscript: @implementation SongList { NSMutableArray *_songs; } - (Song *)replaceSong:(Song *)newSong atIndex:(NSUInteger)idx { Song *oldSong = _songs[idx]; [_songs setObject:newSong atIndexedSubscript:idx]; return oldSong; } @end Pragma Night
  • 52. Keyed Subscripting setObject:atIndexedSubscript: @implementation Database { NSMutableDictionary *_storage; } - (id)replaceObject:(id)newObject forKey:(id <NSCopying>)key { id oldObject = _storage[key]; _storage[key] = newObject; return oldObject; } @end Pragma Night
  • 53. Keyed Subscripting setObject:atIndexedSubscript: @implementation Database { NSMutableDictionary *_storage; } - (id)replaceObject:(id)newObject forKey:(id <NSCopying>)key { id oldObject = _storage[key]; [_storage setObject:newObject forKey:key]; return oldObject; } @end Pragma Night
  • 54. Backward Compatibility !? To deploy back to iOS 5 and iOS 4 you need ARCLite: use ARC or set explicit linker flag: “-fobjc-arc” To make compiler happy, you should add 4 categories: #if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000 @interface NSDictionary(BCSubscripting) - (id)objectForKeyedSubscript:(id)key; @end @interface NSMutableDictionary(BCSubscripting) - (void)setObject:(id)obj forKeyedSubscript:(id )key; @end @interface NSArray(BCSubscripting) - (id)objectAtIndexedSubscript:(NSUInteger)idx; @end @interface NSMutableArray(BCSubscripting) - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx; @end #endif Pragma Night
  • 55. Your Classes Can Be Subscriptable @interface SongList : NSObject - (Song *)objectAtIndexedSubscript:(NSUInteger)idx; - (void) setObject:(Song *)song atIndexedSubscript:(NSUInteger)idx; @end @implementation SongList { NSMutableArray *_songs; } - (Song *)objectAtIndexedSubscript:(NSUInteger)idx { return (Song *)_songs[idx]; } - (void) setObject:(Song *)song atIndexedSubscript:(NSUInteger)idx { _songs[idx] = song; } @end Pragma Night
  • 56. Summary Pragma Night
  • 57. Availability Feature Xcode 4.4+ iOS 6 OSX 10.8 Unordered Method Declarations ✓ Enum With Fixed Underlying Type ✓ @Synthesize by Default ✓ NSNumbers Literals ✓ Boxed Expression Literals ✓ Array Literals ✓ Dictionary Literals ✓ Object Subscripting ✓ ✓* * Partially Required Pragma Night
  • 58. Migration Apple provides a migration tool which is build into Xcode: Edit Refactor Convert to Modern ... Pragma Night
  • 59. Demo Pragma Night
  • 60. Modern Objective-C References • Clang: Objective-C Literals • Apple: Programming with Objective-C • WWDC 2012 – Session 405 – Modern Objective-C • Mike Ash: Friday Q&A 2012-06-22: Objective-C Literals Pragma Night
  • 61. Modern Objective-C Books Pragma Night
  • 62. NSLog(@”Thank you!”); giuseppe.arici@pragmamark.org Pragma Night