Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How can I check user followers?

alomeealomee UAEPosts: 9New Users Noob
edited September 2015 in iOS SDK Development
I have a UITableView which load data from MySql via PHP file from a table (users). In each cell there is a button which is (follow) when ever you press it it's going to be changed to (following). In MySql there is a table called (following).

What I am trying to do is when the table is loading I want to check if the user follow or not, in case he follows then change that button to (following) otherwise leave it as (follow).

This is how I call data;
NSString *queryString = [NSString stringWithFormat:@"http:/MyWebSite/phpfile/UsersSearch.php?UserName=%@&NickName=%@", searchBar.text, searchBar.text];

    NSURL *url = [NSURL URLWithString:[queryString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

    NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

        dispatch_async(dispatch_get_main_queue(), ^{
            if (!data) {
                if (data == NULL) {
                    [UIApplication sharedApplication].networkActivityIndicatorVisible = FALSE;
                }
                return;
            } });
        NSError *parseError;
        NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&parseError];

        dispatch_async(dispatch_get_main_queue(), ^{
            if (!json) {
                [UIApplication sharedApplication].networkActivityIndicatorVisible = FALSE;
                return;
            } });

        NSMutableArray *results = [[NSMutableArray alloc]init];

        for (int i = 0; i < json.count; i++) {
            NSString *userName = json[i][@"UserName"];
            NSString *emailAddress = json[i][@"EmailAddress"];
            NSString *passWord = json[i][@"PassWord"];
            NSString *dateOfRegistered = json[i][@"DateOfRegistered"];
            NSString *userDeviceToken = json[i][@"UserDeviceToken"];
            NSString *agreement = json[i][@"Agreement"];
           NSString *nickName = json[i][@"NickName"];
            NSString *userImageLink = json[i][@"UserImageLink"];

            [results addObject:[[ListOfObjects alloc]initWithUserName:userName andEmailAddress:emailAddress andPassWord:passWord andDateOfRegistered:dateOfRegistered andUserDeviceToken:userDeviceToken andAgreement:agreement andNickNme:nickName andUserImageLink:userImageLink]];
            }

        dispatch_async(dispatch_get_main_queue(), ^{
            self.listArray = results;
            [self.tableView reloadData];
            [UIApplication sharedApplication].networkActivityIndicatorVisible = FALSE;
});
}];
[task resume];


I did try to do this in cellForRowAtIndexPath but it does not work:
if ([cell.lbUserName.text isEqualToString:userFav]) {
            NSLog(@"User like: %@ %@", cell.lbUserName.text, userFav);
            [cell.btFollow setTitle:@"following
Post edited by Stick on
Tagged:
Sign In or Register to comment.