Foros del Web » Programación para mayores de 30 ;) » Programación móvil »

No me va el código

Estas en el tema de No me va el código en el foro de Programación móvil en Foros del Web. Buenas, estoy realizando el manual que he visto en Maestros del Web sobre iPhone y me he quedado estancado en el primer ejercicio, a la ...
  #1 (permalink)  
Antiguo 29/08/2011, 09:55
 
Fecha de Ingreso: noviembre-2010
Mensajes: 234
Antigüedad: 13 años, 5 meses
Puntos: 2
No me va el código

Buenas, estoy realizando el manual que he visto en Maestros del Web sobre iPhone y me he quedado estancado en el primer ejercicio, a la hora de compilar el código que se introduce en el manual me lanza dos errores, les dejo el código en el cual me tira el error,
Código iPhone:
Ver original
  1. //
  2. //  miAppViewController.m
  3. //  miApp
  4. //
  5. //
  6.  
  7. #import "miAppViewController.h"
  8.  
  9. @synthesize miEtiqueta;
  10. -(IBAction)cambiarEtiqueta{
  11. miEtiqueta.text = @"Bazzinga!";
  12. }
  13. -(void)dealloc{
  14. [miEtiqueta release];
  15. [super dealloc];
  16. }
  17.  
  18. @implementation miAppViewController
  19.  
  20.  
  21.  
  22. /*
  23. // The designated initializer. Override to perform setup that is required before the view is loaded.
  24. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  25.     if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
  26.         // Custom initialization
  27.     }
  28.     return self;
  29. }
  30. */
  31.  
  32. /*
  33. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  34. - (void)loadView {
  35. }
  36. */
  37.  
  38.  
  39. /*
  40. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  41. - (void)viewDidLoad {
  42.     [super viewDidLoad];
  43. }
  44. */
  45.  
  46.  
  47. /*
  48. // Override to allow orientations other than the default portrait orientation.
  49. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  50.     // Return YES for supported orientations
  51.     return (interfaceOrientation == UIInterfaceOrientationPortrait);
  52. }
  53. */
  54.  
  55. - (void)didReceiveMemoryWarning {
  56.     // Releases the view if it doesn't have a superview.
  57.     [super didReceiveMemoryWarning];
  58.    
  59.     // Release any cached data, images, etc that aren't in use.
  60. }
  61.  
  62. - (void)viewDidUnload {
  63.     // Release any retained subviews of the main view.
  64.     // e.g. self.myOutlet = nil;
  65. }
  66.  
  67.  
  68. - (void)dealloc {
  69.     [super dealloc];
  70. }
  71.  
  72. @end

Gracias por todo un saludo.
  #2 (permalink)  
Antiguo 30/08/2011, 17:14
Avatar de dual3nigma
Colaborador
 
Fecha de Ingreso: febrero-2010
Ubicación: Ciudad de México
Mensajes: 295
Antigüedad: 14 años, 1 mes
Puntos: 122
Respuesta: No me va el código

Hola ramondevesa

Si sabes ingles te recomiendo el siguiente sitio http://mobile.tutsplus.com

Lamentablemente la "guía" de "maestros del web" no te enseña nada (sin ofender), tu código no funciona por que no te explicaron que tanto @synthesize como @property son características especiales de objective-c que te permiten declarar e implementar automáticamente "getters" y "setters" por lo tanto deben de ir dentro @inferface ... @end (@property) e @implementation ... @end (@synthesize), igual tu función cambiarEtiqueta debe de quedar dentro @implementation ... @end y fijate que tienes repetida la función dealloc

Te dejo mas o menos como se debería de ver, ya que cuando copio y pego el editor hace una cosa horrible de agregar *

Saludos y suerte ;)

Código Objective-C:
Ver original
  1. //
  2. // *miAppViewController.m
  3. // *miApp
  4. //
  5. //
  6. *
  7. #import "miAppViewController.h"
  8. **
  9. @implementation miAppViewController
  10.  
  11. @synthesize miEtiqueta;
  12.  
  13. -(IBAction)cambiarEtiqueta{
  14.     miEtiqueta.text = @"Bazzinga!";
  15. }
  16.  
  17. /*
  18. // The designated initializer. Override to perform setup that is required before the view is loaded.
  19. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  20. * * if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
  21. * * * * // Custom initialization
  22. * * }
  23. * * return self;
  24. }
  25. */
  26. *
  27. /*
  28. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  29. - (void)loadView {
  30. }
  31. */
  32. *
  33. *
  34. /*
  35. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  36. - (void)viewDidLoad {
  37. * * [super viewDidLoad];
  38. }
  39. */
  40. *
  41. *
  42. /*
  43. // Override to allow orientations other than the default portrait orientation.
  44. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  45. * * // Return YES for supported orientations
  46. * * return (interfaceOrientation == UIInterfaceOrientationPortrait);
  47. }
  48. */
  49. *
  50. - (void)didReceiveMemoryWarning {
  51. * * // Releases the view if it doesn't have a superview.
  52. * * [super didReceiveMemoryWarning];
  53. * *
  54. * * // Release any cached data, images, etc that aren't in use.
  55. }
  56. *
  57. - (void)viewDidUnload {
  58. * * // Release any retained subviews of the main view.
  59. * * // e.g. self.myOutlet = nil;
  60. }
  61. *
  62. *
  63. - (void)dealloc {
  64.     [miEtiqueta release];
  65. * * [super dealloc];
  66. }
  67. *
  68. @end
  #3 (permalink)  
Antiguo 30/08/2011, 18:56
 
Fecha de Ingreso: noviembre-2010
Mensajes: 234
Antigüedad: 13 años, 5 meses
Puntos: 2
Respuesta: No me va el código

Muchas gracias dual3nigma ahora no me tira error y me ha compilado sin problemas, pero no me muestra el resultado del manual. Conozco este sitio web y está muy bien en todas las temáticas que tocan pero el problema es ese el idioma...

Bueno muchas gracias por todo y un saludo
  #4 (permalink)  
Antiguo 30/08/2011, 22:06
Avatar de dual3nigma
Colaborador
 
Fecha de Ingreso: febrero-2010
Ubicación: Ciudad de México
Mensajes: 295
Antigüedad: 14 años, 1 mes
Puntos: 122
Respuesta: No me va el código

Me imagino...

Checa el paso 5:

En la ventana “Connections Inspector” arrastrar miEtiqueta hasta la etiqueta creada y la función “cambiarEtiqueta” hasta el botón creado.

Saludos ;)
  #5 (permalink)  
Antiguo 31/08/2011, 00:44
 
Fecha de Ingreso: noviembre-2010
Mensajes: 234
Antigüedad: 13 años, 5 meses
Puntos: 2
Respuesta: No me va el código

Exacto erse fue mi error no hice este paso ahora me sale de forma correcta.
Una duda la tipografía y formato de letra de la palabra Bazzinga! va a ser siempre la misma que el texto que se encuentra?

Etiquetas: código, ios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:00.