其他类的复制字符串中的问题 [英] problem in copy string for other class

查看:86
本文介绍了其他类的复制字符串中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我将请求发送到Web服务器并获得一些结果,然后解析此结果并将此结果字符串存储到其他类对象字符串中.

In my app I am sending a request to the web server and getting some results, then I am parsing this result and storing this result string into other class object string.

例如:

@interface GraphView : UIViewController<UITabBarControllerDelegate> {  

NSMutableString *graphTempString;   

}
@property(nonatomic,retain) NSMutableString *graphTempString;   
@end  

TSUClass .m

TSUClass .m

implementing NSURLConnection(),  
connectionDidFinishLoading(),

-(void) parser:(NSXMLParser *) parser didStartElement:(NSString *) elementName 
 namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *) qName
attributes:(NSDictionary *) attributeDict()  

-(void)parser:(NSXMLParser *)parser 
didEndElement:(NSString *)elementName 
 namespaceURI:(NSString *)namespaceURI 
qualifiedName:(NSString *)qName
{  
    if( [elementName isEqualToString:@"statusTEResult"])  
    {  
        tempString=soapResults;   
        if (grpahCall == YES) {         
            graphViewController=[[GraphView alloc]init];   
            graphViewController.graphTempString=tempString;  

            [self.navigationController pushViewController:graphViewController animated:YES];  
        }  

在调试时,我可以看到graphViewController.graphTempString的值,但是转到GraphView后,我看不到这些值.

When I am debugging I can see the value of graphViewController.graphTempString but after going to GraphView, I am not able to see the values.

我希望有人知道如何解决这个问题.

I hope some one know how to solve this issue.

推荐答案

传递值的简便方法.

[[NSUserDefaults standardUserDefaults]setObject:resultString forKey:@"resultString"];
[[NSUserDefaults standardUserDefaults] synchronize];

在另一个类中使用此值

NSString *resultString=[[NSUserDefaults standardUserDefaults]valueForKey:@"resultString"];

或者您可以这样做.

graphViewController.graphTempString=self.tempString; 

这篇关于其他类的复制字符串中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆