Formacion en movilidad: Conceptos de desarrollo en iOS (I)

284 views

Published on

En esta primera sesión formativa, impartida por Sergi Hernando, CTO de Mobivery, se trataron los siguientes conceptos: Lenguaje (propiedades y protocolos de Objective-C) y Herramientas (Xcode)

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
284
On SlideShare
0
From Embeds
0
Number of Embeds
15
Actions
Shares
0
Downloads
4
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Formacion en movilidad: Conceptos de desarrollo en iOS (I)

  1. 1. CCRTViFormación en movilidadConceptos de desarrollo en iOS1
  2. 2. LenguajeHerramientasHerramientasDel simulador al dispositivo2
  3. 3. iOS 6.1Xcode 4.63
  4. 4. Objective-C@interface Video : NSObject- (void)play;- (void)pause;@end@implementation Video- (void)play {}@end4
  5. 5. Objective-C@interface Video : NSObject- (void)play;- (void)pause;@end@implementation Video- (void)play {}@endIncomplete implementation5
  6. 6. Objective-C[myVideo play];[myVideo pause];6
  7. 7. Objective-CTerminating app due to uncaught exception NSInvalidArgumentException, reason:-[Video pause]: unrecognized selector sent to instance 0x8334620[myVideo play];[myVideo pause]; Thread 1: signal SIGABRT7
  8. 8. Objective-CTerminating app due to uncaught exception NSInvalidArgumentException, reason:-[Video pause]: unrecognized selector sent to instance 0x8334620[myVideo play];[myVideo pause]; Thread 1: signal SIGABRT“un objeto puede enviar un mensaje sin temor aproducir errores en tiempo de ejecución”Wikipedia8
  9. 9. Objective-CTerminating app due to uncaught exception NSInvalidArgumentException, reason:-[Video pause]: unrecognized selector sent to instance 0x8334620[myVideo play];[myVideo pause]; Thread 1: signal SIGABRT“un objeto puede enviar un mensaje sin temor aproducir errores en tiempo de ejecución”No en la runtime library de iOS9
  10. 10. Objective-C10
  11. 11. Objective-CInitializersVideo *myVideo = [[Video alloc] init];// Es equivalente a:Video *myVideo = [Video new];11
  12. 12. Objective-CInitializersVideo *myVideo = [[Video alloc] init];// Es equivalente a:Video *myVideo = [Video new];Video *myVideo = [[Video alloc] initWithURL:theURL];12
  13. 13. Objective-CInitializersVideo *myVideo = [[Video alloc] init];// Es equivalente a:Video *myVideo = [Video new];NSString *theURL = @"http://youtu.be/THERgYM8gBM";Video *myVideo = [[Video alloc] initWithURL:theURL];13
  14. 14. Objective-CInitializersVideo *myVideo = [[Video alloc] init];// Es equivalente a:Video *myVideo = [Video new];NSString *theURL = @"http://youtu.be/THERgYM8gBM";Video *myVideo = [[Video alloc] initWithURL:theURL];- (id)initWithURL:(NSString *)url {! self = [super init];! if(self) {! ! _url = url;! }! return self;}14
  15. 15. Objective-CPropertiesDeclaración@interface Video : NSObject@property NSString *title;@property NSString *url;@end15
  16. 16. Objective-CPropertiesModificadores@interface Video : NSObject@property NSString *title;@property (readonly) NSString *url;- (void)assignURL:(NSString *)url;@end16
  17. 17. Objective-CPropertiesModificadores#import "Video.h"@implementation Video- (void)assignURL:(NSString *)url {// validaciones...! self.url = url;}@end17
  18. 18. Objective-CPropertiesModificadores#import "Video.h"@implementation Video- (void)assignURL:(NSString *)url {// validaciones...! self.url = url;}@endAssignment to readonly property18
  19. 19. Objective-CPropertiesExtensiones#import "Video.h"@interface Video ()@property (readwrite) NSString *url;@end@implementation Video- (void)assignURL:(NSString *)url {// validaciones...! self.url = url;}@end19
  20. 20. Objective-CPropertiesModificadores cool@interface Video : NSObject@property (readonly) BOOL ready;@endif([myVideo ready]) {}20
  21. 21. Objective-CPropertiesModificadores cool@interface Video : NSObject@property (readonly, getter = isReady) BOOL ready;@endif([myVideo isReady]) {}21
  22. 22. Objective-CPropertiesAtomicidad@interface Video : NSObject@property (nonatomic) NSObject *whatever;@end22
  23. 23. Objective-CPropertiesstrong & weak references23
  24. 24. Objective-CPropertiesstrong & weak references24
  25. 25. Objective-CPropertiesstrong & weak references25
  26. 26. Objective-CProtocols@protocol Playable- (void)play;- (void)pause;@optional- (void)fastForward:(int)times;@end26
  27. 27. Objective-CProtocols@interface Video : NSObject <Playable>@end@implementation Video#pragma mark - Playable- (void)play {}- (void)pause {}- (void)fastForward:(int)times {}@end27
  28. 28. Objective-CProtocols@interface PhotoSequence : NSObject <Playable>@end@implementation PhotoSequence#pragma mark - Playable- (void)play {}- (void)pause {}@end28
  29. 29. Objective-CProtocols@interface PhotoSequence : NSObject <Playable>@end@implementation PhotoSequence#pragma mark - Playable- (void)play {}- (void)pause {}@end29
  30. 30. Objective-CBlocksTareas asíncronasdispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);dispatch_async(queue, ^{// Long running task});30
  31. 31. dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);dispatch_async(queue, ^{// Long running task});Objective-CBlocksTareas asíncronas31
  32. 32. dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);dispatch_async(queue, ^{// Long running task});Objective-CBlocksTareas asíncronas32
  33. 33. Xcode33
  34. 34. XcodeCommand LineToolsInstalación34
  35. 35. RubyRubyVersion ManagerInstalación$  export  LANG=en_US.UTF-­‐8$  curl  -­‐L  https://get.rvm.io  |  bash  -­‐s  stable  -­‐-­‐autolibs=3  -­‐-­‐ruby$  rvm  install  1.9.335
  36. 36. Coffee Break!36
  37. 37. RubyRubyVersion ManagerInstalación$  rvm  use  1.9.3-­‐p392$  ruby  -­‐vruby  1.9.3p392  (2013-­‐02-­‐22  revision  39386)  [x86_64-­‐darwin12.3.0]37
  38. 38. Ruby + XcodeCocoaPodsInstalación$  gem  install  cocoapods$  pod  setup...Setup  completed  (read-­‐only  access)$  echo  platform  :ios  >  Podfile$  pod  install...[!]  From  now  on  use  `Workshop.xcworkspace`.38
  39. 39. Xcode⇧⌘NMaster-Detail Application39
  40. 40. XcodeUse Storyboards, Core Data,ARCand include UnitTests40
  41. 41. XcodeCreate local git repository for this projecttry.github.com41
  42. 42. Xcode42
  43. 43. XcodeSchemes &Targets“An scheme defines a collection of targets tobuild, a configuration to use when building, anda collection of tests to execute”* Only one scheme can be active at a time“A target specifies a product to build andcontains the instructions for building theproduct from a set of files in a project or workspace”* A product can be an app or a static library43
  44. 44. XcodeWorkspaces & Projects“A workspace is a document that groupsprojects and other documents so you canwork on them together”* Workspaces provide implicit and explicit relationships among theincluded projects and their targets“A project is a repository for all the files,resources, and information required to buildone or more software products”* Projects define default build settings for all their targets44
  45. 45. XcodeRelación entre unidades de trabajoWorkspaceProjectProjectTargetTargetTargetScheme45
  46. 46. XcodePrimera ejecución⌘R46
  47. 47. XcodePrimera ejecuciónApp simulada47
  48. 48. XcodePreparando para dispositivoFirma del códigoCode Signing Identity: Don’t Code Sign48
  49. 49. XcodePreparando para dispositivoCertificado de desarrolloRequest a Certificate From a Certificate Authority...49
  50. 50. XcodePreparando para dispositivoCertificado de desarrolloRequest is: Saved to disk50
  51. 51. XcodePreparando para dispositivoCertificado de desarrollo51
  52. 52. XcodePreparando para dispositivoCertificado de desarrollo52
  53. 53. XcodePreparando para dispositivoCertificado de desarrolloCER (certificado)+ CSR (clave privada)P12 (PKCS#12)53
  54. 54. XcodePreparando para dispositivoCertificado de desarrolloCER (certificado)+ CSR (clave privada)P12 (PKCS#12)54
  55. 55. XcodePreparando para dispositivoCertificado de desarrolloCertificado y clave privada55
  56. 56. XcodePreparando para dispositivoCertificado de desarrolloFile Format: Personal Information Exchange (.p12)56
  57. 57. XcodePreparando para dispositivoCertificado de desarrollo57
  58. 58. XcodeGit58
  59. 59. Próxima sesión...59

×