我想在uiviewControler.h文件中声明nsstring,并使用这个字符串作为整个uiviewcontroller,我们想使用这些字符串来设置和获取字符串值。我像这样定义了viewcontroller .h文件
NSString *选择字符串;
在一段时间内,它释放了字符串值,并使应用程序崩溃,日志中没有显示任何内容。
有人能帮我吗?
发布于 2010-07-08 21:14:27
您是否正在尝试将其声明为public ivar?(实例变量)您的UIViewController ..?
您需要类似于以下内容的内容:
(表头)
#import <UIKit/UIKit.h>
@interface YourViewController : UIViewController {
NSString *selectedString;
...
...
}
@property (nonatomic, retain) NSString *selectedString;
...
...
@end(实现文件)
#import "YourViewController.h"
@implementation YourViewController
@synthesize selectedString;
...
...
-(void) dealloc {
[selectedString release];
[super dealloc];
}
...
...
@end这是基本的内存管理。如果它在运行时的某个地方崩溃了,你需要clarify...how你是否在赋值字符串/值并使用变量?
https://stackoverflow.com/questions/3203802
复制相似问题