How to add observer for array in other class - iphone

I am building an iOS app in which I want to allow people to order stuff from stores that are registered in my database. To allow my users to see products, companies, etcetera, I need to download array's with the requested information. This is how I do that:
- (void)getOrderItems {
_dbAction = #"getOrderItems";
NSString *post = [NSString stringWithFormat:#"controller=%#&action=%#&orderNumber=%#", #"BakkerFunctions", #"getOrderItems", self.orderNumber];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSURL *url = [NSURL URLWithString:#"http://www.mysite.nl/API/"];
[request setHTTPMethod:#"POST"];
[request setValue:postLength forHTTPHeaderField:#"Content-Length"];
[request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Current-Type"];
[request setHTTPBody:postData];
[request setURL:url];
NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if(conn)
{
NSLog(#"Connection Successful");
}
else
{
NSLog(#"Connection could not be made");
}
}
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data {
NSArray *orderItemsFromDatabase = [[NSArray alloc] init];
orderItemsFromDatabase = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:NULL][#"itemsFromDatabase"];
NSString *datastring = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(#"%# Array:%#", datastring, orderItemsFromDatabase);
//convert array from database in array of custom objects
NSMutableArray *orderItems = [[NSMutableArray alloc] init];
for (int i = 0; i < orderItemsFromDatabase.count; i++) {
[orderItems addObject:
[[Item alloc] initWithItemName:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"itemName"]
itemDescription:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"itemDescription"]
itemCode:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"itemCode"]
itemBarCode:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"itemBarCode"]
itemPrice:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"itemPrice"]
itemQuantity:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"itemQuantity"]
itemUserRemark:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"itemUserRemark"]
itemCompany:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"itemCompany"]
productImageNumber:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"productImageNumber"]
category:[[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"category"]
itemImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://www.imagine-app.nl/ProductImages/%#%#", [[orderItemsFromDatabase objectAtIndex:i]objectForKey:#"productImageNumber"], #".jpg"]]]]]];
}
self.orderItems = [NSArray arrayWithArray:orderItems];
}
the getOrderItems method is a method inside the custom class I have for each order. when the user selects an orders, this method gets called to download the products that belong to this order. Now this process works all fine, but the problem is that the data gets receiver when my TableView already set itself up.
I want to add an observer to check if the amount of products in this array changes, and if it does, i want to update the tableview. I have searched for hours on SO an google, but not much is said about this and nothing useful to me.
any help would be much appreciated! thank you in advance

A simple solution would be to use a MBProgressHUD or a similar control which will display a message saying that please wait while the data is being downloaded. Once, the data is downloaded it will trigger a callback meaning that it has downloaded the data and then you can refresh your UITableView to reflect all the data.

Override the orderItems setter and reload the table in there.
- (void)setOrderItems:(NSArray*)items
{
_items = items;
[self.tableView reloadData];
}

I'm not adding an observer anymore, As soon as my custom class finished processing the received data, it calls the orders view controller. That made that the data is loaded before the tableview is set up and the problem is solved.

Related

How can call json url multiples times in iphone?

Hello I am developing one application as currency converter in that, I have URL it will return only one country currency but my module look like if user select one country then I need to display list of currency converter values of more than one country so I need call josn more than one times.
code is as:
responseData = [[NSMutableData data] retain];
ArrData = [NSMutableArray array];
NSString *strURL = [NSString stringWithFormat:#"http://rate-exchange.appspot.com/currency?from=%#&to=%#&q=1",strtablbase,strto];
NSURL *url = [NSURL URLWithString:strURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
results = [responseString JSONValue];
livevalues=[responseString JSONValue];
With above code I am geting one country values but I need pass one strto values differently
Is it possible?
If yes, please give suggestions & help me out from this problem.
Yes you can use NSOperation Queues to call the different URL or if you are using Asihttprequest this Link may be useful for you :)
responseData = [[NSMutableData data] retain];
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:#"country1"];
[array addObject:#"country2"];
for (NSString *urlString in array) {
strtablbase = [NSString stringWithFormat:#"%#",urlString];
NSString *strURL = [NSString stringWithFormat:#"http://rate-exchange.appspot.com/currency?from=%#&to=%#&q=1",strtablbase,strto];
NSURL *url = [NSURL URLWithString:strURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
Try this..
Of course it is possible to pass different values. Like you already did you can start connections one after another. If the server belongs to you, I would implement a request which returns me all the rates at a time. It saves the time for sending and receiving request. It really does not matter (for waiting time) if you get 100 bytes or 500 bytes in one request.
Otherwise you need to call many requests. Like said you can call one after another and even 2-3 requests at the same time. You can implement the mechanism your self or you can use NSOperationQueue which is made exactly for many requests by Apple.
For more information https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html
And I want yo point the method (of NSURLConnection)
+ (void)sendAsynchronousRequest:(NSURLRequest *)request queue:(NSOperationQueue *)queue completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*))handler

How to upload data from iphone app to mysql data base

I have a EMR app and i want that i may send the data which i have collected like images and voice to server. in data base so how can i do this . Is there any way to send these data to server through post method.
Here is an example of a HTTP Post request
// define your form fields here:
NSString *content = #"field1=42&field2=Hello";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:#"http://www.example.com/form.php"]];
[urlRequest setHTTPMethod:#"POST"];
[urlRequest setHTTPBody:[content dataUsingEncoding:NSISOLatin1StringEncoding]];
// generates an autoreleased NSURLConnection
[NSURLConnection connectionWithRequest:request delegate:self];
Might want to reference http://developer.apple.com/library/ios/#documentation/cocoa/reference/foundation/Classes/NSURLConnection_Class/Reference/Reference.html
This tutorial is also helpful http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service
In that case, you can do follow two ways:
1. if you strictly like to using POST (i like), u can using cocoahttpserver project:
https://github.com/robbiehanson/CocoaHTTPServer
In iphone app, you can do this code to send POST request:
-(NSDictionary *) getJSONAnswerForFunctionVersionTwo:(NSString *)function
withJSONRequest:(NSMutableDictionary *)request;
{
[self updateUIwithMessage:#"server download is started" withObjectID:nil withLatestMessage:NO error:NO];
NSDictionary *finalResultAlloc = [[NSMutableDictionary alloc] init];
#autoreleasepool {
NSError *error = nil;
NSString *jsonStringForReturn = [request JSONStringWithOptions:JKSerializeOptionNone serializeUnsupportedClassesUsingBlock:nil error:&error];
if (error) NSLog(#"CLIENT CONTROLLER: json decoding error:%# in function:%#",[error localizedDescription],function);
NSData *bodyData = [jsonStringForReturn dataUsingEncoding:NSUTF8StringEncoding];
NSData *dataForBody = [[[NSData alloc] initWithData:bodyData] autorelease];
//NSLog(#"CLIENT CONTROLLER: string lenght is:%# bytes",[NSNumber numberWithUnsignedInteger:[dataForBody length]]);
NSString *functionString = [NSString stringWithFormat:#"/%#",function];
NSURL *urlForRequest = [NSURL URLWithString:functionString relativeToURL:mainServer];
NSMutableURLRequest *requestToServer = [NSMutableURLRequest requestWithURL:urlForRequest];
[requestToServer setHTTPMethod:#"POST"];
[requestToServer setHTTPBody:dataForBody];
[requestToServer setTimeoutInterval:600];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[urlForRequest host]];
NSData *receivedResult = [NSURLConnection sendSynchronousRequest:requestToServer returningResponse:nil error:&error];
if (error) {
NSLog(#"CLIENT CONTROLLER: getJSON answer error download:%#",[error localizedDescription]);
[self updateUIwithMessage:[error localizedDescription] withObjectID:nil withLatestMessage:YES error:NO];
[finalResultAlloc release];
return nil;
}
NSString *answer = [[NSString alloc] initWithData:receivedResult encoding:NSUTF8StringEncoding];
JSONDecoder *jkitDecoder = [JSONDecoder decoder];
NSDictionary *finalResult = [jkitDecoder objectWithUTF8String:(const unsigned char *)[answer UTF8String] length:[answer length] error:&error];
[finalResultAlloc setValuesForKeysWithDictionary:finalResult];
[answer release];
[self updateUIwithMessage:#"server download is finished" withObjectID:nil withLatestMessage:NO error:NO];
if (error) NSLog(#"CLIENT CONTROLLER: getJSON answer failed to decode answer with error:%#",[error localizedDescription]);
}
NSDictionary *finalResultToReturn = [NSDictionary dictionaryWithDictionary:finalResultAlloc];
[finalResultAlloc release];
return finalResultToReturn;
}
Don't forget to pack attributes with images to base64.
Finally, if u don't like to keep data, which u send in you mac app, u can send to u database using any database C api. I recommend to using core data to save receive data.

Objective C - POST data using NSURLConnection

I'm very slowly working my way through learning the URL loading system for iOS development, and I am hoping someone could briefly explain the following piece of code:
NSString *myParameters = [[NSString alloc] initWithFormat:#"one=two&three=four"];
[myRequest setHTTPMethod:#"POST"];
[myRequest setHTTPBody:[myParameters dataUsingEncoding:NSUTF8StringEncoding]];
Eventually I would like to be able to create an application that logs into my ISP's website and retrieves how much data I have left for the rest of the month, and I feel as though I should get my head around setHTTPMethod/setHTTPBody first.
Kind regards
This is a pretty simple HTTP request setup; if you have more specific questions you might do better asking those.
NSString *myParameters = #"paramOne=valueOne&paramTwo=valueTwo";
This sets up a string containing the POST parameters.
[myRequest setHTTPMethod:#"POST"];
The request needs to be a POST request.
[myRequest setHTTPBody:[myParameters dataUsingEncoding:NSUTF8StringEncoding]];
This puts the parameters into the post body (they need to be raw data, so we first encode them as UTF-8).
Step 1 : set URL definitions:
// Create the request
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:#"http://192.168.0.232:8080/xxxx/api/Login"]];
// Specify that it will be a POST request
request.HTTPMethod = #"POST";
// This is how we set header fields
[request setValue:#"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:#"Content-Type"];
NSMutableDictionary *postDict = [[NSMutableDictionary alloc] init];
[postDict setValue:#"Login" forKey:#"methodName"];
[postDict setValue:#"admin" forKey:#"username"];
[postDict setValue:#"123456" forKey:#"password"];
[postDict setValue:#"mobile" forKey:#"clientType"];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDict options:0 error:nil];
// Checking the format
NSString *urlString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
// Convert your data and set your request's HTTPBody property
NSString *stringData = [[NSString alloc] initWithFormat:#"jsonRequest=%#", urlString];
//#"jsonRequest={\"methodName\":\"Login\",\"username\":\"admin\",\"password\":\"12345678n\",\"clientType\":\"web\"}";
NSData *requestBodyData = [stringData dataUsingEncoding:NSUTF8StringEncoding];
request.HTTPBody = requestBodyData;
// Create url connection and fire request
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (!theConnection) {
// Release the receivedData object.
NSMutableData *responseData = nil;
// Inform the user that the connection failed.
}
Step 2:
// Declare the value for NSURLResponse URL
//pragma mark NSURLConnection Delegate Methods
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
// A response has been received, this is where we initialize the instance var you created
// so that we can append data to it in the didReceiveData method
// Furthermore, this method is called each time there is a redirect so reinitializing it
// also serves to clear it
_responseData = [[NSMutableData alloc] init];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
// Append the new data to the instance variable you declared
[_responseData appendData:data];
NSError *error=nil;
// Convert JSON Object into Dictionary
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:_responseData options:
NSJSONReadingMutableContainers error:&error];
NSLog(#"Response %#",JSON);
}
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection
willCacheResponse:(NSCachedURLResponse*)cachedResponse {
// Return nil to indicate not necessary to store a cached response for this connection
return nil;
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
// The request is complete and data has been received
// You can parse the stuff in your instance variable now
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
// The request has failed for some reason!
// Check the error var
}
The first line created an string, it can be replaced with:
NSString *myParameters = #"one=two&three=four";
It's written in initWithFormat so you can extend it to assign parameter value.
Second line indicate this is HTTP post request.
The third line, setHTTPBody method take NSData type, so you need to convert string type to NSData using dataUsingEncoding method.
please use below code.
+(void)callapi:(NSString *)str withBlock:(dictionary)block{
NSData *postData = [str dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%lu",(unsigned long)[postData length]];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:#“%#/url”,WebserviceUrl]]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:120.0];
[urlRequest setHTTPMethod:#"POST"];
[urlRequest setValue:postLength forHTTPHeaderField:#"Content-Length"];
[urlRequest setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[urlRequest setHTTPBody:postData];
[NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)
{
if (!data) {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:[NSString stringWithFormat:#"%#",AMLocalizedString(SomethingWentWrong, nil)] forKey:#"error"];
block(dict);
return ;
}
NSError *error = nil;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
//////NSLog(#"%#",dict);
if (!dict) {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:AMLocalizedString(ServerResponceError, nil) forKey:#"error"];
block(dict);
return ;
}
block(dict);
}];
}

php -> JSON -> iPhone

I have an iPhone app which sends a request to a url posting a variable called submit:
+(NSMutableArray*)getQuestions:(NSString*)section from: (NSString*) url{
NSMutableArray *questions = [[NSMutableArray alloc] init];
//connect to database given by url
//NSError *error = nil;
//NSURLResponse *response = nil;
NSMutableString* myRequestString = [[NSMutableString string]initWithFormat:#"section=%#", section];
NSData *myRequestData = [NSData dataWithBytes: [myRequestString UTF8String] length: [myRequestString length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: url]];
[request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"content-type"];
[request setHTTPMethod: #"POST"];
//post section
[request setHTTPBody: myRequestData];
//store them in the array;
return [questions autorelease];
}
My php file:
<?php
//connect to database
function connect() {
$dbh = mysql_connect ("localhost", "abc1", "12345") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("PDS", $dbh);
return $dbh;
}
//store posted data
if(isset($_POST['section'])){
$dbh = connect();
$section = $_POST['section'];
$query = mysql_query("SELECT * FROM QUESTIONS WHERE sectionId = $section;") or die("Error: " . mysql_error());;
$rows = array();
while($r = mysql_fetch_assoc($query)) {
$rows[] = $r;
}
echo '{"questions":'.json_encode($rows).'}';
mysql_close();
}
?>
I have built a model class (Question) in objective c which has the exact properties that each row element has in the rows associative array.
My questions are:
1) How can I read the echo'd JSON array elements and their relative attributes in objective C?
2) How can I create an array of Question objects and map each one to an element in the rows array?
3) What do I have to write in my method "+(NSMutableArray*)getQuestions:(NSString*)section from: (NSString*) url" to capture the reply from the php (the echo)?
EDIT:
Here is the output of the php:
http://dev.speechlink.co.uk/David/get_questionstest.php
UPDATE
Changed method to use ASIHTTPRequest - Cannot deserialise JSON string:
//method to
+(NSDictionary*)getQuestions:(NSString*)sectionId from: (NSString*) url{
NSDictionary *questions;
NSURL *link = [NSURL URLWithString:url];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:link];
[request setPostValue:sectionId forKey:#"section"];
NSError *error = [request error];
[request startAsynchronous];
if (!error) {
//NSString *response = [request responseString];
//store them in the dictionary
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
NSString *json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
questions = [json objectFromJSONString];
NSLog(#"Data: %#", questions); //outputs Data: (null)
[json release];
[request release];
}else{
//UIAlertView to warn users there was an error
}
return questions;
}
Well, lets go through this one step at a time.
You can create a NSDictionary from JSON quite easily by using one of several different JSON parsing libraries. I really enjoy using JSONKit. Once you've imported JSONKit, into your project, you can do something like this:
NSString *url = #"http://dev.speechlink.co.uk/David/get_questionstest.php";
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
NSString *json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSDictionary *questions = [json objectFromJSONString];
[json release];
Now you have an array filled with the questions in your example. Now you can loop through this array and fill your data with the data in the array. Now lets be practical. It would be easier if you just had to manage one object instead of four for each question, wouldn't it? Lets make a class that contains one question each instance.
Interface:
#interface Question : NSObject {
NSString *questionId;
NSString *question;
NSString *questionNumber;
NSString *sectionId;
}
#property(copy)NSString *questionID;
#property(copy)NSString *question;
#property(copy)NSString *questionNumber;
#property(copy)NSString *sectionId;
#end
And implementation:
#implementation Question
#synthesize questionId, question, questionNumber, sectionID;
#end
Now that's just a basic example. Nothing fancy. Now you can loop through the array you had before and create "question" objects that contain each question's data. For my purposes, suppose you have a NSMutableArray named questionsArray that contain the questions you want to use. We'll loop through the dictionary and add the questions from the dictionary into the questionsArray array.
for (NSDictionary *q in questions) {
/* Create our Question object and populate it */
Question *question = [[Question alloc]init];
question.questionId = [q objectForKey:#"questionId"];
question.question = [q objectForKey:#"question"];
question.questionNumber = [q objectForKey:#"questionNumber"];
question.sectionId = [q objectForKey:#"sectionId"];
/* Add it to our question (mutable) array */
[questionsArray addObject:question];
[question release];
}
Tada! Now you have an array filled with Question objects. Any time you want to look at a property on any of the question objects, you can just simply access that property. For example, to grab the first question's number, you can just do this:
NSString *q1Number = [questionsArray objectAtIndex:0].questionNumber;
Please note this is all untested, as I don't have my compiler with me. It should get you started, though. =)
Edit: You were doing your request completely wrong. Try this:
+(NSDictionary*)getQuestions:(NSString*)sectionId from: (NSString*) url{
NSDictionary *questions = nil;
NSURL *link = [NSURL URLWithString:url];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:link];
[request setPostValue:sectionId forKey:#"section"];
NSError *error = [request error];
[request startSynchronous];
if (!error) {
NSData *response = [request responseData];
NSString *json = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
questions = [json objectFromJSONString];
[json release];
} else{
//UIAlertView to warn users there was an error
}
[request release];
return questions;
Take a look at Stig Brautaset's excellent JSON parser at GitHub.
And there are even a couple of sample projects included.
From your PHP, one would expect the parser to produce and array of NSDictionary objects. I'm not sure what you mean by question 2, but you can then iterate through the array and create custom "Question" objects with the NSDictionary values.
Hope this helps.
Didn't see that you added a third question. This is answered in the "TweetStream" example above. I would suggest that you use the NSURLConnectionDelegate methods as described by Apple.

Creating a new NSURLConnection inside of connectionDidFinishLoading

I have a NSURLConnection that gets data from a JSON web service, and everything works fine. I'm using it to post something to the server and get a success response.
After that call I want to initiate another NSURLConnection to refresh the data, so I'm doing so inside the connectionDidFinishLoading method, however this second connection isn't calling connectionDidFinishLoading when it is done loading.
Can I not initiate a NSURLConnection from inside the connectionDidFinishLoading method?
EDIT: Below is the code. I subclassed NSURLConnection to include a Tag NSString, calling the new class NSURLConnectionHelper. I'm using this to differentiate which connection has called the connectionDidFinishLoading.
- (void)connectionDidFinishLoading:(NSURLConnectionHelper *)connection
{
if([connection.Tag isEqual:#"NewMessage"]){
NSString *jsonString = [[NSString alloc] initWithData:receivedNewMessageData encoding:NSASCIIStringEncoding];
NSDictionary *results = [jsonString JSONValue];
[jsonString release];
[connection release];
if ([[results objectForKey:#"MessageAdded"] isEqual:#"True"]) {
User *newUser = [[User alloc] init];
[newUser retrieveFromUserDefaults];
if([newUser IsLoggedIn]){
Message *message = (Message *)[messages objectAtIndex: 0];
NSString *urlAsString = // url for webservice goes here
NSURL *url = [NSURL URLWithString:urlAsString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
NSURLConnectionHelper *connection1 = [[NSURLConnectionHelper alloc] initWithRequest:request delegate:self];
connection1.Tag = #"GetLatestMessages";
[request release];
if (connection1) {
receivedLatestMessagesData = [[NSMutableData data] retain];
} else {
// Inform the user that the connection failed.
}
}
}
}else if([connection.Tag isEqual:#"GetLatestMessages"]){
//do some other stuff but this code is never reached
}
}
I'm not familiar with NSURLConnectionHelper but it looks like you're never starting the connection.
I ended up having a space in my web service url, once I corrected that it worked.