Pregunta

Tenía un mensaje exc_bad_access en mi consola. Leí sobre las variables de entorno nszombieEnabled y Mallocstackloggingnocompact on este sitio. Creé mis variables de entorno: NszombieEnabled = sí y MallocstackloggingNocompact = 1. En la consola, vi

2010-03-01 19: 13: 46.924 Cruznomad [7952: 207] ***-[CfString StringByadingPercentApesusingEncoding:]: Mensaje enviado a la instancia clasificada 0x58448e0

Luego en el mensaje (GDB), lo hice Info Malloc-History 0x58448e0, que me dio:

Alloc: Block address: 0x058448e0 length: 64
Stack - pthread: 0xa0b33500 number of frames: 25
    0: 0x98e089bc in malloc_zone_malloc
    1: 0x21516aa in _CFRuntimeCreateInstance
    2: 0x2152bf8 in __CFStringCreateImmutableFunnel3
    3: 0x21567d9 in CFStringCreateCopy
    4: 0x21742fc in _CFStringCreateWithFormatAndArgumentsAux
    5: 0xdb546 in -[NSPlaceholderString initWithFormat:locale:arguments:]
    6: 0xdb4d8 in +[NSString stringWithFormat:]
    7: 0x23aa3 in -[BuisnessCardViewController viewDidLoad] at /Users/.../Classes/BuisnessCardViewController.m:85
    8: 0x3d6796 in -[UIViewController view]
    9: 0x347b4 in -[gm_menuViewController btn5_Pressed:] at /Users/.../Classes/menuViewController.m:535
   10: 0x357459 in -[UIApplication sendAction:to:from:forEvent:]
   11: 0x3baba2 in -[UIControl sendAction:to:forEvent:]
   12: 0x3bcdc3 in -[UIControl(Internal) _sendActionsForEvents:withEvent:]
   13: 0x3bbb0f in -[UIControl touchesEnded:withEvent:]
   14: 0x370e33 in -[UIWindow _sendTouchesForEvent:]
   15: 0x35a81c in -[UIApplication sendEvent:]
   16: 0x3610b5 in _UIApplicationHandleEvent
   17: 0x2984ed1 in PurpleEventCallback
   18: 0x2197b80 in CFRunLoopRunSpecific
   19: 0x2196c48 in CFRunLoopRunInMode
   20: 0x298378d in GSEventRunModal
   21: 0x2983852 in GSEventRun
   22: 0x362003 in UIApplicationMain
   23: 0x2c8c in main at /Users/.../source/main.m:14
   24: 0x2bfa in start

La línea 7 dice que el problema estaba en la línea 85 de BuisnessCardViewController.m. Esa línea está aquí:

fullAddress = [NSString stringWithFormat:@"%@ %@", fullAddress, myString];

Estoy agregando el contenido de dirección completa y mystring y almacenarlo de nuevo dirección completa.

Si estoy interpretando esto correctamente, parece que después de esta línea, dirección completa se desanimó. Cuando dejo caer un punto de interrupción y rondas la variable, su valor dice "fuera del alcance".

dirección completa Funciona más tarde en este método. Lo uso para enviar para enviar a Google para la geocodificación inversa en la línea 164 del mismo método.

NSString    *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", [fullAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

Incluso aquí, dice "fuera de alcance". Estoy perplejo ... ¿algún consejo?

¡Gracias!

Thomas

¿Fue útil?

Solución

En la mayoría de los casos, esto sucede cuando no retiene un atributo que es objeto y le envía mensajes tardíos en otros métodos, tarde.

Entonces, donde se inicializan algunas cuerdas, intente:

[fullAddress retain];

o

[myString retain];

dependiendo de cuál se inicialice en otro método.

Otros consejos

¿Has intentado agregar cadena con formato?

fullAddress = [NSString stringWithFormat:@"%@ %@", fullAddress, myString];

con:

- (NSString *)stringByAppendingFormat:(NSString *)format ...

como esto:

[fullAddress stringByAppendingFormat:@" %@", myString];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top