2011-05-23 48 views
0

不能在TTPostController检索成员对象:PostController的方法不能在TTPostController检索成员对象:PostController的方法

我一直在努力弄清楚为什么我无法返回任何使用TTPostController当我的成员对象:PostController中方法发送HTTP请求。这是我正在使用的代码。

页眉:

@interface NewReplyViewController : TTPostController <TTPostControllerDelegate> { 
    NSString * _thread_id; 
} 

@property (nonatomic, assign) NSString * thread_id; 

-(id)initWithThreadId:(NSString *)threadId; 

@end 

实现:

@synthesize thread_id = _thread_id; 

-(id)initWithThreadId:(NSString *)threadId { 
    self = [super initWithNibName:nil bundle:nil]; 

    if (self) { 
     self.delegate = self; 
     self.thread_id = threadId; 
     self.title  = kPostReplyPhrase; 

     self.navigationItem.rightBarButtonItem.title = kPostPhrase; 
    } 

    return self; 
} 

- (void)postController:(TTPostController *)postController 
      didPostText:(NSString *)text 
      withResult:(id)result { 

    NSLog(@"postController:postController self.threadid = %@", self.thread_id); 
} 

当我到达的NSLog部分,它会尝试按下发送按钮后返回的对象的线程ID,应用程序崩溃没有太多的细节。堆栈跟踪显示我的_thread_id对象,但我无法弄清楚为什么我无法达到它。关于我可能做错什么的想法?

以下是关于崩溃和一些细节的堆栈跟踪:
http://i.stack.imgur.com/NL2tD.png

Thread 1, Queue : com.apple.main-thread 
    #0 0x01058657 in ___forwarding___() 
#1 0x01058522 in __forwarding_prep_0___() 
#2 0x00a99fcb in _NSDescriptionWithLocaleFunc() 
#3 0x010d0c1d in __CFStringAppendFormatCore() 
#4 0x01018507 in _CFStringCreateWithFormatAndArgumentsAux() 
#5 0x010a01ee in _CFLogvEx() 
#6 0x00b179a4 in NSLogv() 
#7 0x00b17913 in NSLog() 
#8 0x0000a7a0 in -[NewReplyViewController postController:didPostText:withResult:] at /Users/Ken/iOS/Forums/NewReplyViewController.m:59 
#9 0x00048b8f in -[TTPostController dismissAnimationDidStop]() 
#10 0x00369fb9 in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]() 
#11 0x00369e4b in -[UIViewAnimationState animationDidStop:finished:]() 
#12 0x0027999b in run_animation_callbacks(double, void*)() 
#13 0x0021e651 in CA::timer_callback(__CFRunLoopTimer*, void*)() 
#14 0x010c88c3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__() 
#15 0x010c9e74 in __CFRunLoopDoTimer() 
#16 0x010262c9 in __CFRunLoopRun() 
#17 0x01025840 in CFRunLoopRunSpecific() 
#18 0x01025761 in CFRunLoopRunInMode() 
#19 0x01c2e1c4 in GSEventRunModal() 
#20 0x01c2e289 in GSEventRun() 
#21 0x00347c93 in UIApplicationMain() 
#22 0x00001fa9 in main() 

回答

0

有关的NSString @财产,始终使用副本:

@property (nonatomic, copy) NSString * thread_id; 

AFAIK只有两种情况下,您可以使用@property(assign):

  • F或文字类型(即非对象),例如:int,float,NSUInteger,CGPoint等
  • 当您只想弱对比一个超过类对象的对象时,最常见的例子是delegate和view controller:@property (nonatomic, assign) UIViewController *viewController

p/S:弱引用防止循环依赖,例如:控制器保留视图,然后查看保持控制器,以便在所述端部都不能释放

+0

这很好地工作!感谢您的解释,现在更有意义。 – Ken 2011-05-23 09:32:22

相关问题