CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
//build an info object and convert to json
NSError *requestError;
NSHTTPURLResponse *responseHTTP;
NSError *dictError;
//get projectList
Get project details
NSMutableURLRequest *requestForProjectListrequestForProjectDetails;
requestForProjectDetails = [[NSMutableURLRequest alloc] init];
NSString *projectListRequestString = [requestForProjectDetails setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@/projects/%@",[CSS getDefaultAPIURL],[CSS getSlug],proj.mID]]];
[requestForProjectList setURL:[NSURL URLWithString:projectListRequestString]];
[requestForProjectListrequestForProjectDetails setHTTPMethod:@"GET"];
[requestForProjectListrequestForProjectDetails setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[requestForProjectListrequestForProjectDetails setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];
NSData *responseForProjectListresponseForProjectDetails = [NSURLConnection sendSynchronousRequest:requestForProjectListrequestForProjectDetails returningResponse:&responseHTTP error:&requestError];
[requestForProjectListrequestForProjectDetails release];
if (responseForProjectListresponseHTTP.statusCode == NULL200) {
// Login Failed
}
// else {
Success, we have a project detail dictionary
NSError *error;
NSArrayNSDictionary *projectListprojectDetails = [NSJSONSerialization JSONObjectWithData:responseForProjectListresponseForProjectDetails options:NSJSONReadingMutableContainersNULL error:&errordictError];
BOOL success = [[ProjectManager sharedProjectManager] loadProjectsFromData:projectList];
// Time to process this project details as you want/need
[proj processProjectDetails:projectDetails];
if (!success)}else{
// Download Failed
to Load Projects List
}
return;
}
|