As i am deleting the json data .whenever i am deleting the json data i have to remove that particular data in the tableview. Also whenever i trying to remove the data in the first row it throws the exception like "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 1 from section 0 which only contains 1 rows before the update'" and app getting crashed
can anyone suggest me what was problem in the following coding?
- (IBAction)deletebutton:(id)sender {
NSString *userid = [[NSUserDefaults standardUserDefaults]
stringForKey:#"UserId"];
NSString *encodeddistrictvalue = [selecteddistrictvalue stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
NSString *encodedPanchaytvalue = [selectedpanchayatvalue stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
NSString *urlStr = [NSString stringWithFormat:#"my json url",encodeddistrictvalue,encodedPanchaytvalue,taxtypevariable,selctedassessmentno,userid];NSURL *url = [NSURL URLWithString:urlStr];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response,
NSData *data, NSError *connectionError)
{
if (data.length > 0 && connectionError == nil)
{
NSDictionary *dictionaryvalue = [NSJSONSerialization JSONObjectWithData:data
options:0
error:NULL];
NSString *code = [[dictionaryvalue objectForKey:#"code"] stringValue];
NSLog(#"the response string value is %#",code);
if ([code intValue]==1) {
NSLog(#"deletd sucessfully");
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:#"Alert"
message:#"Are u sure u want to delete the table data"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:#"yes"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
{
[assessmentnumber removeObject:selctedassessmentno ];
[self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:#"expandingCell"];
[_tableview reloadData];
}
}];
[alert addAction:yesButton];
[self presentViewController:alert animated:YES completion:nil];
alert.view.tintColor = [UIColor blackColor];
}
}
} ];
}
put this viewDidLoad
[self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:#"expandingCell"];
You can use begin & end update:
Table.beginUpdates()
for i in 0 ..< sections[section].items.count
{
Table.reloadRows(at: [IndexPath(row: i, section: section)], with: .automatic)
}
Table.endUpdates()
Related
I have trouble with creating Pause/Resume download methods in my Objective-C osx app, I have tried some of the answers I found here but nothing seems to work.
Here is my code: `-(void)pauseDownload:(id)sender {
if(!downloadTask) return;
[downloadTask cancelByProducingResumeData:^(NSData * _Nullable resumeData) {
if (!resumeData) return;
[self setDownloadResumeData:resumeData];
[self setDownloadTask:nil];
}];
NSString *datastring = [[NSString alloc] initWithData:downloadResumeData encoding:NSUTF8StringEncoding];
isDownloading = NO;
NSLog(#"data %#", datastring);}`
Continue method:
-(void)continueDownload:(id)sender {
if (!self.downloadResumeData) {
return;
}
self.downloadTask = [manager.session downloadTaskWithResumeData:self.downloadResumeData];
[self.downloadTask resume];
[self setDownloadResumeData:nil];}
And download request with download task:
-(void)downloadRequest:(NSString *)url toDirectory:(NSString *)directoryName atIndex:(NSInteger) rowIndex {
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURL *URL = [NSURL URLWithString:url];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
NSString *downloadDirectoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:#"downloadPath"];
NSURL *downloadURL;
if (directoryName != nil || ![directoryName isEqualToString:#""]) {
downloadURL = [self createDownloadDirectoryIn:downloadDirectoryPath withName:directoryName];
} else {
downloadURL = [NSURL URLWithString:[[NSUserDefaults standardUserDefaults] objectForKey:#"downloadFolderPath"]];
}
downloadTask = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
NSLog(#"%#", downloadProgress);
// [self downloadStartedWithDownloadId:downloadID andDeviceId:userDeviceID];
isDownloading = YES;
NSNumber *downloadPercentage = [NSNumber numberWithInteger:downloadProgress.fractionCompleted *100];
progressArray[rowIndex] = downloadPercentage;
[self updateProgressBars];
} destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
return [downloadURL URLByAppendingPathComponent:[response suggestedFilename]];
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
[[files objectAtIndex:self.tableOfContents.selectedRow] setIsFinishedDownloading:YES];
// [self downloadFinishedWithDownloadID:downloadID andDeviceID:userDeviceID];
NSLog(#"File downloaded to: %#", filePath);
}] ;
[downloadTask resume];}
Appreciate any help.
I have a method that posts HTTP data, After getting the response from API I want to display an UIAlertController on the basis of status codes.
Suppose the status code I got is 409, So the controller will say "data already exists".
How to present alert controller and in which class, service class or any other view controller?
ViewController.h
- (IBAction)logIn:(id)sender {
if (username.text == nil || [password.text isEqualToString:#""])
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:
#"all the fields are mendetary"
message:#"missing username or password " preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction
actionWithTitle:#"OKAY" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action)
{
//[self dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:action];
[self presentViewController:alert animated:YES completion:nil];
}
else
{
[[service SharedInstance] logIn:[NSDictionary dictionaryWithObjectsAndKeys:username.text,#"username",password.text,#"password",nil] params:#"logIn" block:^(const BOOL success, id resultObject, NSError *error )
{
// [self performSegueWithIdentifier:#"Loggedin" sender:self];
}];
}
username.text =#"";
password.text =#"";
}
Service.m
-(void)logIn:(NSDictionary *)Details params:(NSString *)params block:(ResponseBlock)block{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSError *error;
NSString *URL = #"http://localhost:8080";
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:nil delegateQueue:nil];
NSString *requestURL = [URL stringByAppendingString:#"/api/signupUser"];
NSURL *url = [NSURL URLWithString:requestURL]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:120.0]; NSData *data = [params dataUsingEncoding:NSDataBase64Encoding64CharacterLineLength];
NSString *base64Encoded = [data base64EncodedStringWithOptions:0];
NSLog(#"base64Encoded%#",base64Encoded);
NSString *basicString = #"Basic";
basicString = [NSString stringWithFormat:#"%#%#",basicString,base64Encoded];
NSLog(#"basicString%#",basicString);
[request addValue:#"application/json" forHTTPHeaderField:#"Content-Type"];
[request addValue:basicString forHTTPHeaderField:#"Authorization"];
[request setHTTPMethod:#"POST"];
NSData *bodyData = [NSJSONSerialization dataWithJSONObject:Details options:0 error:&error];
[request setHTTPBody:bodyData];NSURLSessionTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * data, NSURLResponse *response, NSError *error)
{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
long statusCode =[httpResponse statusCode];
NSLog(#"response status code: %ld", statusCode);
f (error)
{
block(NO, response,error);
}
else
{
NSError *err = nil;
id responseData = [NSJSONSerialization
JSONObjectWithData:data options:kNilOptions error:&err];
NSDictionary* headers= [(NSHTTPURLResponse *)response allHeaderFields];
NSLog(#"all header fields %#",headers);
[defaults removeObjectForKey:#"userToken"];
NSLog(#"token %#",[defaults valueForKey:#"userToken"]);
NSDate *expireDate = [[NSDate date]dateByAddingTimeInterval:60*25];
[defaults setObject:expireDate forKey:#"sessionDate"];
if(err)
{
block(NO, response, error);
}
else
{
block(YES, responseData,nil);
}
[task cancel];
}
}];
[task resume];
}
#end
It looks like you are making some http call from a service file. There are few options here:
Implement delegate of your service class in ViewController to perform any task there.
Use blocks.
Use framework like Rx here.
or if you just need to display the alert add the alert to current window e.g.
I have created an extension for this purpose:
extension UIAlertController {
/// display alert with custom number of buttons
static func presentAlert(_ title: String?, message: String?, alertButtonTitles: [String], alertButtonStyles: [UIAlertActionStyle], vc: UIViewController, completion: #escaping (Int)->Void) -> Void
{
let alert = UIAlertController(title: title,
message: message,
preferredStyle: UIAlertControllerStyle.alert)
for title in alertButtonTitles {
let actionObj = UIAlertAction(title: title,
style: alertButtonStyles[alertButtonTitles.index(of: title)!], handler: { action in
completion(alertButtonTitles.index(of: action.title!)!)
})
alert.addAction(actionObj)
}
vc.present(alert, animated: true, completion: nil)
}
}
use:
UIAlertController.presentAlert("My Title", message: "My message", alertButtonTitles: "OK", alertButtonStyles: [.default], vc: (UIApplication.shared.keyWindow?.rootViewController)!, completion: { (btnIndex) in
})
Above code is adding UiAlerController over window.
i am very new to objective c .I am trying to delete the table row from uitableview. whenever i trying to delete the first row of the tableview i am getting the following exception "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 1 from section 0 which only contains 1 rows before the update'" i don't what is the mistake i done.
can anyone please suggest me what is the mistake i done?
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle==UITableViewCellEditingStyleDelete)
{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:#"alert"
message:#"Are you want to delete the selected date."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* canclebutton = [UIAlertAction
actionWithTitle:#"CANCEL"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
//Handle your yes please button action here
}];
UIAlertAction* continuebutton = [UIAlertAction
actionWithTitle:#"CONTINUE"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
NSString *userid = [[NSUserDefaults standardUserDefaults]
stringForKey:#"UserId"];
NSString *encodeddistrictvalue = [selecteddistrictvalue stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
NSString *encodedPanchaytvalue = [selectedpanchayatvalue stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
NSString *urlStr = [NSString stringWithFormat:#"my web service url"];NSURL *url = [NSURL URLWithString:urlStr];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response,
NSData *data, NSError *connectionError)
{
if (data.length > 0 && connectionError == nil)
{
NSDictionary *dictionaryvalue = [NSJSONSerialization JSONObjectWithData:data
options:0
error:NULL];
NSString *code = [[dictionaryvalue objectForKey:#"code"] stringValue];
NSLog(#"the response string value is %#",code);
if ([code intValue]==1) {
NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];
NSLog(#"the second button to naviagte %#",selectedIndexPath);
[assessmentnumber removeObjectAtIndex:indexPath.row];
[tableView reloadData];
}
else
{
NSLog(#"alredy deleted");
[assessmentnumber removeAllObjects];
[_tableview reloadData];
}
}
} ];
}];
[alert addAction:canclebutton];
[alert addAction:continuebutton];
[self presentViewController:alert animated:YES completion:nil];
alert.view.tintColor = [UIColor blackColor];
}
}
I'm trying to build and login and logout application, but not able to login please help me to set default user id and password through which i would be able go to the next page
You can try this code it will help you :
-(void)login
{
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
NSURL *url = [NSURL URLWithString:#"http://www.example.com/pm/api/login"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[request addValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[request addValue:#"*/*" forHTTPHeaderField:#"Accept"];
[request setHTTPMethod:#"POST"];
NSString *mapData = [NSString stringWithFormat:#"username=admin&password=123456&api_key=bf45c093e542f057c123ae7d6"];
NSData *postData = [mapData dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
[request setHTTPBody:postData];
NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if(error == nil)
{
NSString * text = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if(error!=nil)
{
NSLog(#"error = %#",error);
}
dispatch_async(dispatch_get_main_queue(), ^{
[self checkUserSuccessfulLogin:json];
});
}
else{
NSLog(#"Error : %#",error.description);
}
}];
[postDataTask resume];
}
- (void)checkUserSuccessfulLogin:(id)json
{
// NSError *error;
NSDictionary *dictionary = (NSDictionary *)json;
if ([[dictionary allKeys] containsObject:#"login"])
{
if ([[dictionary objectForKey:#"login"] boolValue])
{
if(checkBoxSelected == YES)
{
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
NSString* textField1Text = usernameField.text;
[defaults setObject:textField1Text forKey:#"textField1Text"];
NSString *textField2Text = passwordField.text;
[defaults setObject:textField2Text forKey:#"textField2Text"];
[defaults synchronize];
}
NSString *strID = [[NSUserDefaults standardUserDefaults] stringForKey:#"textField1Text"];
NSString *strPWD = [[NSUserDefaults standardUserDefaults] stringForKey:#"textField2Text"];
[[NSUserDefaults standardUserDefaults] setValue:[dictionary objectForKey:#"user_id"] forKey:#"CurrentUserLoggedIn"];
NSString *strUser = [[NSUserDefaults standardUserDefaults] stringForKey:#"CurrentUserLoggedIn"];
[[NSUserDefaults standardUserDefaults]synchronize];
[self saveLoginFileToDocDir:dictionary];
ItemManagement *i = [[ItemManagement alloc]init];
[self.navigationController pushViewController:i animated:YES];
}
else
{
NSLog(#"Unsuccessful, Try again.");
UIAlertView *alertLogin = [[UIAlertView alloc]initWithTitle:#"Error" message:#"Wrong Username Or Password" delegate:self cancelButtonTitle:#"cancel" otherButtonTitles:nil];
[alertLogin show];
}
}
}
- (void)saveLoginFileToDocDir:(NSDictionary *)dictionary
{
NSArray *pListpaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *pListdocumentsDirectory = [pListpaths objectAtIndex:0];
NSString *path = [pListdocumentsDirectory stringByAppendingPathComponent:#"Login.plist"];
BOOL flag = [dictionary writeToFile:path atomically:true];
if (flag)
{
NSLog(#"Saved");
}
else
{
NSLog(#"Not Saved");
}
}
- (NSDictionary *)getLoginFileFromDocDir
{
NSArray*pListpaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString*pListdocumentsDirectory = [pListpaths objectAtIndex:0];
NSString *path = [pListdocumentsDirectory stringByAppendingPathComponent:#"Login.plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
return dict;
}
-(void)checkboxSelected:(id)sender
{
checkBoxSelected = !checkBoxSelected;
[checkbox setSelected:checkBoxSelected];
}
to set a default user in app you may use the code below
In your AppDelegate.m
if ([[NSUserDefaults standardUserDefaults]boolForKey:#"IsFirstTime"])
{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
ViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:#"ViewController"];
self.window.rootViewController = vc;
}
else
{
[[NSUserDefaults standardUserDefaults]setBool:YES forKey:#"IsFirstTime"];
[[NSUserDefaults standardUserDefaults]synchronize];
}
then #import your AppDelegate.m class to the class where you put code for login
AppDelegate *delegate;
- (void)viewDidLoad
{
[super viewDidLoad];
delegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
}
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
NSURL *url = [NSURL URLWithString:#"http://43.252.88.251/jsonandroid/"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[request addValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[request addValue:#"*/*" forHTTPHeaderField:#"Accept"];
[request setHTTPMethod:#"POST"];
NSString *mapData = [NSString stringWithFormat:#"username=admin&password=123456&api_key=bf45c093e542f057c123ae7d6"];
NSData *postData = [mapData dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
[request setHTTPBody:postData];
NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if(error == nil)
{
NSString * text = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if(error!=nil)
{
NSLog(#"error = %#",error);
}
dispatch_async(dispatch_get_main_queue(), ^{
[self checkUserSuccessfulLogin:json];
});
}
else{
NSLog(#"Error : %#",error.description);
}
}];
[postDataTask resume];
}
- (void)checkUserSuccessfulLogin:(id)json
{
// NSError *error;
NSDictionary *dictionary = (NSDictionary *)json;
if ([[dictionary allKeys] containsObject:#"login"])
{
if ([[dictionary objectForKey:#"login"] boolValue])
{
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
NSString* textField1Text = usernamefield.text;
[defaults setObject:textField1Text forKey:#"textField1Text"];
NSString *textField2Text = passwordfield.text;
[defaults setObject:textField2Text forKey:#"textField2Text"];
[defaults synchronize];
}
NSString *strID = [[NSUserDefaults standardUserDefaults] stringForKey:#"textField1Text"];
NSString *strPWD = [[NSUserDefaults standardUserDefaults] stringForKey:#"textField2Text"];
[[NSUserDefaults standardUserDefaults] setValue:[dictionary objectForKey:#"user_id"] forKey:#"CurrentUserLoggedIn"];
NSString *strUser = [[NSUserDefaults standardUserDefaults] stringForKey:#"CurrentUserLoggedIn"];
[[NSUserDefaults standardUserDefaults]synchronize];
[self saveLoginFileToDocDir:dictionary];
/* ItemManagement *ItemManagement = [[ItemManagement alloc]init];
[self.navigationController pushViewController:ItemManagement animated:YES];
*/
}
else
{
NSLog(#"Unsuccessful, Try again.");
/* UIAlertView *alertLogin = [[UIAlertView alloc]initWithTitle:#"Error" message:#"Wrong Username Or Password" delegate:self cancelButtonTitle:#"cancel" otherButtonTitles:nil];
[alertLogin show];*/
UIAlertController *alert = [UIAlertController alertControllerWithTitle:#"Title" message:#"Hello" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelbutton = [UIAlertAction actionWithTitle:#"" style:UIAlertActionStyleCancel handler:nil];
//UIAlertAction *oktext= [UIAlertAction actionWithTitle:oktext style:UIAlertActionStyleDefault handler:nil];
[alert addAction:cancelbutton];
//[alert addAction:oktext];
}
}
- (void)saveLoginFileToDocDir:(NSDictionary *)dictionary
{
NSArray *pListpaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *pListdocumentsDirectory = [pListpaths objectAtIndex:0];
NSString *path = [pListdocumentsDirectory stringByAppendingPathComponent:#"Login.plist"];
BOOL flag = [dictionary writeToFile:path atomically:true];
if (flag)
{
NSLog(#"Saved");
}
else
{
NSLog(#"Not Saved");
}
}
- (NSDictionary *)getLoginFileFromDocDir
{
NSArray*pListpaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString*pListdocumentsDirectory = [pListpaths objectAtIndex:0];
NSString *path = [pListdocumentsDirectory stringByAppendingPathComponent:#"Login.plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
return dict;
}
I am using the code below to send request and reading the results via PHP file which connected to MySql. The code is working but it gives the results twice. I am using UIAlert and also its appear twice.
Her is the code:
// to check if the user name chosen has been registred bu some one else
NSString *userName = self.textUserName.text;
NSString *queryString = [NSString stringWithFormat:#"http:/MyWebSite/PHP.php?userName=%#",userName];
NSURLRequest *theRequest=[NSURLRequest
requestWithURL:[NSURL URLWithString:
queryString]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[NSURLConnection sendAsynchronousRequest:theRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if (error) {
} else {
NSString *responseText = [[NSString alloc] initWithData:data encoding: NSASCIIStringEncoding];
NSLog(#"Response: %#", responseText);
if ([responseText isEqualToString:#"null"]) {
// if the user is not registered then show the tick image
self.userNameTickImage.hidden = NO;
}else {
// to show alert if found user is already taken
UIAlertView *message = [[UIAlertView alloc] initWithTitle:NSLocalizedString(#"appName", nil)
message:NSLocalizedString(#"userNameRegisterd", nil)
delegate:nil
cancelButtonTitle:NSLocalizedString(#"done", nil)
otherButtonTitles:nil];
[message show];
// to return nill value to the user name text
self.textUserName.text = #"";
}
NSString *newLineStr = #"\n";
responseText = [responseText stringByReplacingOccurrencesOfString:#"<br />" withString:newLineStr];
}
}];
And her is the result in Xcode:
2015-05-17 13:02:34.851 App[3710:141871] Response: {"1":{"userName":"admin"}}
2015-05-17 13:02:35.052 App[3710:141871] Response: {"1":{"userName":"admin"}}