【发布时间】:2012-10-27 19:09:50
【问题描述】:
我有一个使用-void 方法设置的字符串值,我需要在类方法+ 中检索该字符串
我无法将 + 更改为 - 方法,因此我需要找出另一种方法来检索该字符串。
@synthesize folderPathName=_folderPathName;
-(void)loadFolderPathName:(NSString *)folder{
_folderPathName=[[NSString alloc] initWithString:folder];
}
+(NSString *)getDocumentsDirectory
{
// NSString *pathwithFoldername=[NSString stringWithFormat:@"Documents/%@",_folderPathName];
NSString *documentsDirectory = [NSHomeDirectory()
stringByAppendingPathComponent:pathwithFoldername];
return documentsDirectory;
}
我尝试过类似的东西
-(NSString *) getFolderPathName{
return _folderPathName;
}
但这都不是
NSString *pathwithFoldername=[FileUtils getFolderPathName];
或者这个允许的函数调用
NSString *pathwithFoldername=[self getFolderPathName];
如何获取该字符串并在 + 方法中使用它?
【问题讨论】: