chuleta xcode top

Download Chuleta Xcode Top

If you can't read please download the document

Upload: josep-comas

Post on 18-Nov-2014

399 views

Category:

Documents


1 download

TRANSCRIPT

GENERAR UNA BASE DE DATOS CON CORE DATAPASO 1 : ABRIR EN XCODE EL FICHERO MINOMBRE.XCDATAMODEL PASO 2 : AADIR NOMBRE FICHERO + CONFIGURAR LOS REGISTROS

PASO 3: GENERAR AUTOMATICAMANTE LAS CLASES .H y .M.

RELLENAR UNA ARRAY CON DATOS DE CORE DATAPASO 1: INSERTAR EN EL CONTROLADOR DE LA VISTA .M EL CODIGO SIGUIENTE:

PASO 1 : DECLARAR E INICIALIZAR EL ARRAY PASO 2: IMPORTAR LA CABECERA .H DEL FICHERO PRINCIPAL APPDELEGATE + IMPORTAR LA CABEZERA .H DEL FICHERO DEL CONTROLADOR DE LA VISTA QUE CONTROLA LA VENTANA PARA MOSTRAR LA TABLA CON LOS DATOS.

PASO 3 : ESTE CODIGO DE ARRIBA PERMITE INSERTAR + ORDENAR, ETC LOS DATOS DEL FICHERO A LA ARRAY Y LO ENLAZA CON LA VISTA. PASO 4 :PONER ESTE CODIGO EN EL APPDELEGATE .H.- (void)createEditableCopyOfDatabaseIfNeeded;

PASO 5 : PONER ESTE CODIGO EN EL APPDELEGATE .M.- (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [self createEditableCopyOfDatabaseIfNeeded]; [window addSubview:tabcontroller.view]; [window makeKeyAndVisible]; } - (void)createEditableCopyOfDatabaseIfNeeded { // First, test for existence - we don't want to wipe out a user's DB NSFileManager *fileManager = [NSFileManager defaultManager];

NSString *documentDirectory = [self applicationDocumentsDirectory]; NSString *writableDBPath = [documentDirectory stringByAppendingPathComponent:@"iBountyHunter.sqlite"]; BOOL dbexits = [fileManager fileExistsAtPath:writableDBPath]; if (!dbexits) { // The writable database does not exist, so copy the default to the appropriate location. NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"iBountyHunter.sqlite"]; NSError *error; BOOL success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error]; if (!success) { NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]); } } }

PERSONALIZAR UNA TABLA PARA PRESENTAR DATOS

PASO 1 :#pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section { return [items count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell... Fugitive *fugitive = [items objectAtIndex:indexPath.row]; cell.textLabel.text = fugitive.name; return cell; }

VER LOS DATOS DE UN FICHERO EN OTRA PANTALLAPASO 1: CREAR LA VISTA XIB EN USER INTERFACE + LAS CLASES .H y .M.

PASO 2: EN EL MODULO CONTROLADOR DE LA TABLA PONER LO SIGUIENTE:

PASO 3: RETOCAR LAS LINEAS EN EL FICHERO CABEZERA

AADIR CAMPOS A UNA BASE DE DATOS COREPASO 1:

PASO 2:

AADIR CAMPOS Y CONTROLES PARA HACER ACCIONES Y COMPORTAMIENTOS

CODIGO PARA DETECTAR CAMBIOS EN LOS DATOS

FILTRAR DATOS EN UNA BASE DE DATOSPASO 1:

We need to set a predicate on our NSFetchRequest

NSPredicate is a deceptively simple class that lets us express logical constraints on our NSFetchRequest. You use entity and attribute names along with comparison operators to express your constraint information. You can create a basic NSPredicate with a string format syntax similar to NSString, like this:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@captured == YES]; [request setPredicate:predicate];But NSPredicates dont stop with simple attribute comparisons. Apple provides several subclasses like NSComparisonPredicate, NSCompoundPredicate, and NSExpression as well as a complex grammar for wildcard matching, object graph traversal, and more. For iBountyHunter, a simple attribute condition is all we need to get Bobs view working.

PASO 2:

PASO 3:

Core Data controller classes provide efficient results handlingThe code for both the FugitiveListViewController and the CapturedListViewController is in viewWillAppear. The problem is that viewWillAppear gets called every time the view is shown, which means were reloading all of the fugitives and all of the captured fugitives every time, regardless of whether anythings changed. We could move the code to viewDidLoad, but that only gets called when the views are loaded from their nibs. That causes two problems. First, if we mark a fugitive as captured, the Captured List wont reflect that since it only loads its data once. The second problem is that viewDidLoad gets called before our applicationDidFinishLaunching, which means the views will try to get their data before the app delegate gets a chance to copy the master database in place. What we need is a better way to manage our fetched data.

HACER VENTANAS DE I INFORMACION

HACER MENUS EMERGENTES ACTION SHEETS

CORE LOCATION-LOCALIZACION VIA GPS