Я застрял с глупым плохим доступом, так как много часов.Я совершенно не могу его найти.Я надеюсь, что некоторые из вас смогут показать мне ответ на свет.В приведенном ниже коде это выглядит в строке: NSString * stringCallVisit = [[NSString alloc]initWithFormat:.....
Я не могу понять, все объекты являются локальными для метода, кроме параметра theIntervention.
если я комментирую метод NSString * stringCallVisit = [[NSString alloc]initWithFormat:...
плохой доступ донне появляется, даже если я делаю id obj = callVisit.injectionby;
вместо;Так что я полагаю, что плохой доступ не из объекта callVisit, а определенно из объекта stringCallVisit.Но почему я просто создаю его на том месте, где появляется плохой доступ.
Спасибо за вашу помощь,
-(NSString*)getCallVisitForIntervention:(Intervention*)theIntervention
{
NSManagedObjectContext *context = [iPad_TestAppDelegate mainContext];
NSError *error;
NSFetchRequest *requestCallVisit = [[NSFetchRequest alloc]init];
[requestCallVisit setEntity:[NSEntityDescription entityForName:@"CallVisit" inManagedObjectContext:context]];
NSPredicate *predicateInterventionID = [NSPredicate predicateWithFormat:@"intervention_id = %@",theIntervention.id];
[requestCallVisit setPredicate:predicateInterventionID];
NSMutableArray *callVisits = [[context executeFetchRequest:requestCallVisit error:&error]mutableCopy];
NSString *xml = @"<CallVisits>";
for(CallVisit *callVisit in callVisits)
{
NSString * stringCallVisit = [[NSString alloc]initWithFormat:
@"<CallVisit>"
"<id>%@</id>"
"<injectionby>%@</injectionby>"
"<injectionspot>%@</injectionspot>"
"<intervention_id>%@</intervention_id>"
"<fls>%d</fls>"
"<weight>%d</weight>"
"<height>%d</height>"
"<painAtInjection>%d</painAtInjection>"
"<created>%@</created>"
"<siteReaction>%d</siteReaction>"
"<technicalComplain>%d</technicalComplain>"
"<field1>%d</field1>"
"<field2>%d</field2>"
"<riskCompliance>%d</riskCompliance>"
"<reasonCompliance>%@</reasonCompliance>"
"<placebo>%@</placebo>"
"<needlereceived>%@</needlereceived>"
"<compliance>%d</compliance>"
"<psychologicalCondition>%d</psychologicalCondition>"
"<keepsegment>%d</keepsegment>"
"</CallVisit>",
callVisit.id,
callVisit.injectionby,
callVisit.injectionspot,
callVisit.intervention_id,
[callVisit.fls doubleValue],
[callVisit.weight doubleValue],
[callVisit.height doubleValue],
[callVisit.painAtInjection intValue],
callVisit.created,
[callVisit.siteReaction intValue],
[callVisit.technicalComplain intValue],
[callVisit.field1 intValue],
[callVisit.field2 intValue],
[callVisit.riskCompliance intValue],
callVisit.reasonCompliance,
callVisit.placebo,
callVisit.needlereceived,
[callVisit.compliance intValue],
[callVisit.psychologicalCondition intValue],
[callVisit.keepsegment intValue]];
xml = [xml stringByAppendingString:stringCallVisit];
[stringCallVisit release];
id obj = callVisit;
}
[callVisits release];
[requestCallVisit release];
xml = [xml stringByAppendingString:@"</CallVisits>"];
return xml;
}
РЕДАКТИРОВАТЬ:
Я сделал то, что вы сказали, но я не могу понять журнал, и я не получил адрес для информации malloc.Я немного растерялся:)
РЕДАКТИРОВАТЬ Вот журнал.Но это странно, но знаю, что приложение вылетает в другом месте.
GuardMalloc[iPad Test-7405]: Failed to VM allocate 397648 bytes
GuardMalloc[iPad Test-7405]: Explicitly trapping into debugger!!!
sharedlibrary apply-load-rules all
Error in re-setting breakpoint 1:
Catchpoint 2 (throw)iPad Test(7405,0xaccab2c0) malloc: recording malloc stacks to disk using standard recorder
GuardMalloc[iPad Test-7405]: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
GuardMalloc[iPad Test-7405]: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
No memory available to program: call to malloc failed
Error in re-setting breakpoint 1:
Error in re-setting breakpoint 1:
GuardMalloc[iPad Test-7405]: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Current language: auto; currently objective-c
GuardMalloc[iPad Test-7405]: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
No memory available to program: call to malloc failed
GuardMalloc[iPad Test-7405]: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
No memory available to program: call to malloc failed
GuardMalloc[iPad Test-7405]: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
No memory available to program: call to malloc failed
(gdb)