0

I am trying to select a row from a table view when a push notification is received.

I have myprojectAppDelegate.h

#import <UIKit/UIKit.h>
#import "iw.h"
#import "Bookmark.h"


@interface myprojectAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
    UIWindow               *window;
    UITabBarController     *tabBarController;
    UINavigationController *navigationController;
    NSMutableArray                  *tableData;
    NSMutableArray                  *imagesList;
    IBOutlet Bookmark               *tableCell;
}

@property (nonatomic, retain) IBOutlet UIWindow               *window;
@property (nonatomic, retain) IBOutlet UITabBarController     *tabBarController;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property(nonatomic, retain) NSMutableArray                  *tableData;
@property(nonatomic, retain) NSMutableArray                  *imagesList;

- (BOOL)getIsLaunched;
- (void)showService;
- (void)showMessage;
- (void) loadLogoList;
+ (const NSString*)getVersion;
+ (const NSString*)getXMLversionURL;
+ (NSMutableDictionary *)logos;
+ (void)setLogos:(NSMutableDictionary *)newDictionary;
- (void)checkVersion;

@end

and implementing the didReceiveRemoteNotification in myprojectAppDelegate.m file But the tableview is implemented in another class bookmarklist.m when the app start after launch options it navigates to bookmarklist.m and displays the table view.

I want to access that tableview which is in bookmarklist.m and select a row in the table when ever i receive a push notification.

please help me with this. i am new to ios programming.

Thanks.

Vardhan D G
  • 316
  • 1
  • 4
  • 13

2 Answers2

1

Use the UITableView class method:

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath

This will return the cell at the indexPath you give it.

If you only want to select the cell, use this class method:

- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition
Jasper
  • 7,031
  • 3
  • 35
  • 43
1

You can add an observer method in your bookmarklist.m class like this

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newMessageReceived:) name:@"NEWMESSAGE" object:nil];

and add this observer method in the same class

-(void)newMessageReceived:(NSNotification *) notification{
       //Here you can select the row you want to be selected
}

Then in your didReceiveRemoteNotification in appDelegate file, post a notification like this and pass the data you want to post in object parameter.

[[NSNotificationCenter defaultCenter] postNotificationName:@"NEWMESSAGE" object:nil]; 

Hope this helps.

HRM
  • 2,097
  • 6
  • 23
  • 37