Want to display text from a UITableViewCell to a Local Notification alertBody

When the cell grays out, I want to create a Local Notification. In the alertBody want to have the text read what is in the cell and send that to the local notification. Only the Alert! displays without the .alertBody. Have tried several different approaches but no success to get the local alert to display what is in the grayed out cell.

TableViewController.h

@property (nonatomic, retain) UITextField *transmitterNameLabel;

TableViewController.m

@synthesize transmitterNameLabel;

...

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"MyReusableCell";
SightingsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell != nil) {
    Transmitter *transmitter = [self.transmitters objectAtIndex:indexPath.row];

    // Update the transmitter text
    cell.transmitterNameLabel.text = transmitter.name;

    // Update the transmitter avatar (icon image)
    NSInteger avatarID = [UserSettingsRepository getAvatarIDForTransmitterID:transmitter.identifier];
    NSString *imageFilename = [NSString stringWithFormat:@"avatar_%02ld.png", (long)avatarID];
    cell.transmitterIcon.image = [UIImage imageNamed:imageFilename];

    if ([self isTransmitterAgedOut:transmitter]) {
        [self grayOutSightingsCell:cell];
        //Add Local Notification
        NSDate *AlertTime = [[NSDate date] dateByAddingTimeInterval:3];
        UIApplication *app = [UIApplication sharedApplication];
                              UILocalNotification *notifyAlert = [[UILocalNotification alloc] init];
                              if (notifyAlert) {
                                  notifyAlert.fireDate = AlertTime;
                                  notifyAlert.timeZone = [NSTimeZone defaultTimeZone];
                                  notifyAlert.repeatInterval = 0;
                                  notifyAlert.soundName = @"soundeffect.mp3";
                                  notifyAlert.alertBody = transmitterNameLabel.text;
                                  notifyAlert.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
                                  [app scheduleLocalNotification:notifyAlert];
                                   }
    } else {
        [self updateSightingsCell:cell withTransmitter:transmitter];
    }
}
return cell;

Answers


When you update the label, you call cell.transmitterNameLabel.text = transmitter.name; which updates the transmitterNameLabel property in the SightingsTableViewCell class object cell, but when setting alertBody, you call notifyAlert.alertBody = transmitterNameLabel.text; which is not a property of the cell object and thus may be empty/different.

Perhaps you should try notifyAlert.alertBody = cell.transmitterNameLabel.text;?


Need Your Help

How To Make a “Corrupt” File

unit-testing testing functional-testing

Suppose, during testing, you wish to test how the software handles a "corrupt" file.

stop page from postback onkeypress event

javascript asp.net firefox postback onkeypress

I have a single page asp.net 4.0 form with couple of textboxes in divs which I programmatically show/hide. On one particular textbox on my form with onkeypressevent defined like this

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.