SlideShare a Scribd company logo
1 of 15
Download to read offline
Persistencia de datos
      con Parse
    aalbagarcia@gmail.com
         @aalbagarcia
Creando y guardando
                      objetos
#pragma mark PTGroupDataSourceProtocol
-(void) addGroup:(NSString *)group
{
   PFObject *newGroup = [PFObject objectWithClassName:@"Group"];
   [newGroup setObject:group forKey:@"name"];
   [newGroup saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
      if(succeeded)
      {
          dispatch_async(dispatch_get_main_queue(), ^{
              [self getGroupsAndReloadDataInBackground];
          });

      }
    }];
    NSLog(@"Saving group %@", group);
}




                                                                             Doc
Creando y guardando
                    objetos

–   save
–   save:
–   saveInBackground
–   saveInBackgroundWithBlock:
–   saveInBackgroundWithTarget:selector:
–   saveEventually
–   saveEventually:




                                           Doc
Borrando objetos
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath
{
  if (editingStyle == UITableViewCellEditingStyleDelete) {
    PFObject *group = [groups objectAtIndex:indexPath.row];
    [group deleteInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
      if(succeeded & !error)
      {
        NSMutableArray *newGroups = [groups mutableCopy];
        [newGroups removeObjectAtIndex:indexPath.row];
        groups = [newGroups copy];
        dispatch_async(dispatch_get_main_queue(), ^{
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                       withRowAnimation:UITableViewRowAnimationFade];
        });
      }
    }];
  }
}
Creando y guardando de
                objetos

–   delete
–   delete:
–   deleteInBackground
–   deleteInBackgroundWithBlock:
–   deleteInBackgroundWithTarget:selector:
–   deleteEventually
Viendo los objetos
Relaciones
- (void) addPerson:(NSDictionary *)data
{
   PFObject *group = [data objectForKey:@"group"];
   PFObject *person = [PFObject objectWithClassName:@"Person"];
   [person setObject:[data objectForKey:@"firstName"] forKey:@"firstName"];
   [person setObject:[data objectForKey:@"lastName"] forKey:@"lastName"];
   [person setObject:[data objectForKey:@"email"] forKey:@"email"];
   [person setObject:[data objectForKey:@"twitter"] forKey:@"twitter"];
   PFRelation *memberOf = [person relationforKey:@"memberOf"];
   [memberOf addObject:group];
   [person saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
      if(succeeded)
      {
          dispatch_async(dispatch_get_main_queue(), ^{
              [self loadDataInBackground];
          });

          //We cannot create the inverse relation until the object is saved
          PFRelation *relation = [group relationforKey:@"members"];
          [relation addObject:person];
          [group saveInBackground];
        }
        else
        {
           NSLog(@"Person could not be saved.");
                                                                              Doc
        }
  }];                                                                         API
Relaciones




             Doc
             API
La demo es muy artesanal

¿Qué herramientas nos da parse?
PFLoginViewController




                        Doc
PGSignUpViewController




                     Doc
PFQueryTableViewController




                        Doc
PFImage


PFImageView *imageView = [[PFImageView alloc] init];
imageView.image = [UIImage imageNamed:@"..."]; // placeholder image
imageView.file = (PFFile *)[someObject objectForKey:@"picture"]; // remote image

[imageView loadInBackground];




                                                                                   Doc

More Related Content

What's hot

Softshake - Offline applications
Softshake - Offline applicationsSoftshake - Offline applications
Softshake - Offline applicationsjeromevdl
 
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talkMooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talkJose Luis Martínez
 
Mongo db query docuement
Mongo db query docuementMongo db query docuement
Mongo db query docuementzarigatongy
 
PostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersPostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersAmanda Gilmore
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway ichikaway
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤Takahiro Inoue
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
How to calculate the optimal undo retention in Oracle
How to calculate the optimal undo retention in OracleHow to calculate the optimal undo retention in Oracle
How to calculate the optimal undo retention in OracleJorge Batista
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsAlexander Rubin
 
File System Operations
File System OperationsFile System Operations
File System OperationsG.C Reddy
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2Takahiro Inoue
 
与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库YUCHENG HU
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensionserwanl
 

What's hot (20)

MongoDb and NoSQL
MongoDb and NoSQLMongoDb and NoSQL
MongoDb and NoSQL
 
Litebox
LiteboxLitebox
Litebox
 
Softshake - Offline applications
Softshake - Offline applicationsSoftshake - Offline applications
Softshake - Offline applications
 
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talkMooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
 
Mongo db query docuement
Mongo db query docuementMongo db query docuement
Mongo db query docuement
 
PostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersPostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL Superpowers
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
 
jQuery's Secrets
jQuery's SecretsjQuery's Secrets
jQuery's Secrets
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤
 
MongoDB Oplog入門
MongoDB Oplog入門MongoDB Oplog入門
MongoDB Oplog入門
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
How to calculate the optimal undo retention in Oracle
How to calculate the optimal undo retention in OracleHow to calculate the optimal undo retention in Oracle
How to calculate the optimal undo retention in Oracle
 
Latinoware
LatinowareLatinoware
Latinoware
 
MySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of ThingsMySQL flexible schema and JSON for Internet of Things
MySQL flexible schema and JSON for Internet of Things
 
File System Operations
File System OperationsFile System Operations
File System Operations
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2
 
Database api
Database apiDatabase api
Database api
 
与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Mongo db for C# Developers
Mongo db for C# DevelopersMongo db for C# Developers
Mongo db for C# Developers
 

Viewers also liked

Plantillajornadasversion2 100708010347-phpapp01
Plantillajornadasversion2 100708010347-phpapp01Plantillajornadasversion2 100708010347-phpapp01
Plantillajornadasversion2 100708010347-phpapp01Alfonso Alba
 
Perl6 expresiones regulares
Perl6 expresiones regularesPerl6 expresiones regulares
Perl6 expresiones regularesAlfonso Alba
 
Bienvenido a la republica independiente de las pruebas unitarias con Core Data
Bienvenido a la republica independiente de las pruebas unitarias con Core DataBienvenido a la republica independiente de las pruebas unitarias con Core Data
Bienvenido a la republica independiente de las pruebas unitarias con Core DataAlfonso Alba
 

Viewers also liked (6)

Git
GitGit
Git
 
Plantillajornadasversion2 100708010347-phpapp01
Plantillajornadasversion2 100708010347-phpapp01Plantillajornadasversion2 100708010347-phpapp01
Plantillajornadasversion2 100708010347-phpapp01
 
Usuarios ipad
Usuarios ipadUsuarios ipad
Usuarios ipad
 
Perl6 expresiones regulares
Perl6 expresiones regularesPerl6 expresiones regulares
Perl6 expresiones regulares
 
Perl5 hashes
Perl5 hashesPerl5 hashes
Perl5 hashes
 
Bienvenido a la republica independiente de las pruebas unitarias con Core Data
Bienvenido a la republica independiente de las pruebas unitarias con Core DataBienvenido a la republica independiente de las pruebas unitarias con Core Data
Bienvenido a la republica independiente de las pruebas unitarias con Core Data
 

Similar to Persistencia de datos con Parse

Introduction to Parse backend for mobile developers
Introduction to Parse backend for mobile developersIntroduction to Parse backend for mobile developers
Introduction to Parse backend for mobile developersGrigor Yeghiazaryan
 
Parse: 5 tricks that won YC Hacks
Parse: 5 tricks that won YC HacksParse: 5 tricks that won YC Hacks
Parse: 5 tricks that won YC HacksThomas Bouldin
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCAWhymca
 
Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots DeepAnshu Sharma
 
Dpilot - Source Code with Snapshots
Dpilot - Source Code with SnapshotsDpilot - Source Code with Snapshots
Dpilot - Source Code with SnapshotsKritika Phulli
 
Source Code for Dpilot
Source Code for Dpilot Source Code for Dpilot
Source Code for Dpilot Nidhi Chauhan
 
iOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful BackendiOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful BackendStefano Zanetti
 
Introduction to Parse
Introduction to ParseIntroduction to Parse
Introduction to Parseabeymm
 
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleDrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleAlexander Varwijk
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationAbdul Malik Ikhsan
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyHuiyi Yan
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Satoshi Asano
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntityBasuke Suzuki
 
Array of objects.pptx
Array of objects.pptxArray of objects.pptx
Array of objects.pptxRAGAVIC2
 
solving little problems
solving little problemssolving little problems
solving little problemsAustin Ziegler
 

Similar to Persistencia de datos con Parse (20)

Introduction to Parse backend for mobile developers
Introduction to Parse backend for mobile developersIntroduction to Parse backend for mobile developers
Introduction to Parse backend for mobile developers
 
What's Parse
What's ParseWhat's Parse
What's Parse
 
Parse: 5 tricks that won YC Hacks
Parse: 5 tricks that won YC HacksParse: 5 tricks that won YC Hacks
Parse: 5 tricks that won YC Hacks
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots
 
Dpilot - Source Code with Snapshots
Dpilot - Source Code with SnapshotsDpilot - Source Code with Snapshots
Dpilot - Source Code with Snapshots
 
Source Code for Dpilot
Source Code for Dpilot Source Code for Dpilot
Source Code for Dpilot
 
iOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful BackendiOS App with Parse.com as RESTful Backend
iOS App with Parse.com as RESTful Backend
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Introduction to Parse
Introduction to ParseIntroduction to Parse
Introduction to Parse
 
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleDrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journey
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
iOS5 NewStuff
iOS5 NewStuffiOS5 NewStuff
iOS5 NewStuff
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntity
 
Moar tools for asynchrony!
Moar tools for asynchrony!Moar tools for asynchrony!
Moar tools for asynchrony!
 
Array of objects.pptx
Array of objects.pptxArray of objects.pptx
Array of objects.pptx
 
solving little problems
solving little problemssolving little problems
solving little problems
 

Persistencia de datos con Parse

  • 1. Persistencia de datos con Parse aalbagarcia@gmail.com @aalbagarcia
  • 2. Creando y guardando objetos #pragma mark PTGroupDataSourceProtocol -(void) addGroup:(NSString *)group { PFObject *newGroup = [PFObject objectWithClassName:@"Group"]; [newGroup setObject:group forKey:@"name"]; [newGroup saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if(succeeded) { dispatch_async(dispatch_get_main_queue(), ^{ [self getGroupsAndReloadDataInBackground]; }); } }]; NSLog(@"Saving group %@", group); } Doc
  • 3. Creando y guardando objetos – save – save: – saveInBackground – saveInBackgroundWithBlock: – saveInBackgroundWithTarget:selector: – saveEventually – saveEventually: Doc
  • 4. Borrando objetos - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { PFObject *group = [groups objectAtIndex:indexPath.row]; [group deleteInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if(succeeded & !error) { NSMutableArray *newGroups = [groups mutableCopy]; [newGroups removeObjectAtIndex:indexPath.row]; groups = [newGroups copy]; dispatch_async(dispatch_get_main_queue(), ^{ [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; }); } }]; } }
  • 5. Creando y guardando de objetos – delete – delete: – deleteInBackground – deleteInBackgroundWithBlock: – deleteInBackgroundWithTarget:selector: – deleteEventually
  • 7.
  • 8. Relaciones - (void) addPerson:(NSDictionary *)data { PFObject *group = [data objectForKey:@"group"]; PFObject *person = [PFObject objectWithClassName:@"Person"]; [person setObject:[data objectForKey:@"firstName"] forKey:@"firstName"]; [person setObject:[data objectForKey:@"lastName"] forKey:@"lastName"]; [person setObject:[data objectForKey:@"email"] forKey:@"email"]; [person setObject:[data objectForKey:@"twitter"] forKey:@"twitter"]; PFRelation *memberOf = [person relationforKey:@"memberOf"]; [memberOf addObject:group]; [person saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if(succeeded) { dispatch_async(dispatch_get_main_queue(), ^{ [self loadDataInBackground]; }); //We cannot create the inverse relation until the object is saved PFRelation *relation = [group relationforKey:@"members"]; [relation addObject:person]; [group saveInBackground]; } else { NSLog(@"Person could not be saved."); Doc } }]; API
  • 9.
  • 10. Relaciones Doc API
  • 11. La demo es muy artesanal ¿Qué herramientas nos da parse?
  • 15. PFImage PFImageView *imageView = [[PFImageView alloc] init]; imageView.image = [UIImage imageNamed:@"..."]; // placeholder image imageView.file = (PFFile *)[someObject objectForKey:@"picture"]; // remote image [imageView loadInBackground]; Doc

Editor's Notes

  1. Comentar en la documentación cómo se borran los registros