iOS: Passing parsed values from soap webservice in NSObject class back to UIViewController

I don't know why this is being so difficult but I can't get this to work. Here's my simple problem:

I have a UIViewController that calls paring class type of NSObject class that does the parsing jobs.

I just need the parsed data values to be returned back to that ViewController.

Could any body provide me a simple step or any suggestion to do this... I really need this issue to be solved for my project and the deadline is near...

Thanks Here is my code:


@implementation ViewController
- (void)viewDidLoad
    [super viewDidLoad];
    wsClass *ws = [[wsClass alloc] init];
    [ws initParsing];


@interface ProjListClass : NSObject

@property(nonatomic,strong) NSString * PROJECT_ID;
@property(nonatomic,strong) NSString * SHORT_DESCR;
@property(nonatomic,strong) NSString * LOCATION;

@interface wsClass : NSObject <NSXMLParserDelegate>{
ProjListClass *proj_obj;
ProjListClass *prj;

NSMutableData* webData;
NSMutableString *soapResults;
NSURLConnection *conn;

NSXMLParser *xmlParser;

@property(nonatomic,strong) NSMutableArray * arrHouses;
@property(nonatomic, strong)     NSXMLParser *xmlParser;

-(void) initParsing;


#import "wsClass.h"

@implementation ProjListClass

@implementation wsClass

@synthesize arrHouses, xmlParser;

-(void) initParsing{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

    soapResults = [[NSMutableString alloc] init];
    arrHouses=[[NSMutableArray alloc]init];

    NSString *soapMessage = [NSString stringWithFormat:
                         @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                         "<soap:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap=\"\">\n"
                         "<Projects_List xmlns=\"\"/>\n"
   NSURL *url = [NSURL URLWithString:@""];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

conn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( conn )
    webData = [NSMutableData data];
    NSLog(@"theConnection is NULL");
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
   NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
    if (xmlParser)
  xmlParser = [[NSXMLParser alloc] initWithData: webData];
  [xmlParser setDelegate: self];
  [xmlParser setShouldResolveExternalEntities:YES];
  [xmlParser parse];

 -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
 namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
 else if([elementName isEqualToString:@"ProjectsListDetails"])
    [arrHouses addObject:proj_obj];

soapResults = nil;
soapResults = [[NSMutableString alloc]init];


See below Steps would give you some idea

1) Inside the Your NSOBject Class say ParsingModel class, Create Protocol Inside that parsing Class where you doing parsing. give name whatever you want.

   @protocol  WebServiceResponseDelegate <NSObject>

  - (void)didRecieveResponseData:(NSMutableArray*)array;


Implement this protocol to the Parsing Class like this @protocol WebServiceResponseDelegate;

Create Property Inside the Parsing Class so that could set the Delegate from confirming class..

      @property   (nonatomic, assign) id<WebServiceResponseDelegate>delegate;

and Just need to send the Parsed Data To the Confirming Class i.e from where you created parsing object

   //say didRecieveResponse this is the method called when you completed parsing of data

 // - (void)didRecieveResponse
  // {   
  //  if([delegate respondsToSelector:@selector(didRecieveResponseData)])
 //    {
  //    //pass populated dataSource which would have the Parsed Data.

  //    [delegate didRecieveResponseData:parsedData];
 //    //  parsedData is the NUMtableArray or any other DataSource.


EDIT: See below is the delegate method called when you finished the paring successfully

  - (void)parserDidEndDocument:(NSXMLParser *)parser{
    //pass populated dataSource which would have the Parsed Data.  

    //before check whether that delegate method confirmed by the class.

    if([delegate respondsToSelector:@selector(didRecieveResponseData)])
       [delegate didRecieveResponseData:parsedData];

   //  parsedData is the NUMtableArray or any other DataSource.

  // called when the parser has completed parsing. If this is encountered, the parse was need to call

2) And Inside the Confirming Class as You said UIViewController say DataViewController define That delegate Method in your DataViewController.h adopt that protocol like this DataViewController<WebServiceResponse>

And set Delegate from the point at where you creating the parsing model class like this

  ParsingModel * paring = [ParsingModel alloc]init];
  [paring setWebServiceResponseDelegate:self];

 //definition of callback delegate method
 - (void)didRecieveResponseData:(NSMutableArray*)array
 //here you would have the Parsed Data now you can use it as you want


I hope everything clear to you.

You can create a protocol in your NSObject class, trigger it when all your parsing operations have finished and set your view controller as a delegate.

Need Your Help

Problems with panel.border in ggplot

r ggplot2 panel

I would like to make the border of my plots a certain color other than black. I notice that if I set the default theme to theme_bw() using:

x64 DLL export function names

c++ dll 64bit name-mangling

I am trying to port a 32-bit dll (and application) to 64-bit and I have managed to build it without errors. When trying to load it with my 64-bit application I noticed that the exported function na...