Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (AppDataObject*) theAppDataObject
- {
- id<AppDelegateProtocol> theDelegate = (id<AppDelegateProtocol>) [UIApplication sharedApplication].delegate;
- AppDataObject* theDataObject;
- theDataObject = (AppDataObject*) theDelegate.theAppDataObject;
- return theDataObject;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- tempImageString = (((championList *) [self.champions objectAtIndex:indexPath.row]).championImage);
- AppDataObject *theDataObject = [self theAppDataObject];
- NSLog(@"tempIm-g = %@",tempImageString);
- theDataObject.imageString = tempImageString;
- NSLog(@"theAppDataObject.imageString = %@",theDataObject.imageString);
- [self.navigationController popToRootViewControllerAnimated:YES];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- AppDataObject* theDataObject = [self theAppDataObject];
- UIImage *tempImage = [UIImage imageNamed:theDataObject.imageString];
- NSLog(@"temp image = %@",tempImage);
- [choosenChampionImageView setImage:tempImage];
- }
- AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
- appdelegate.imageString = tempImageString;
- @interface championsListTableViewController : UITableViewController
- {
- NSString *tempImageString;
- AppDataObject* theDataObject;
- }
- @property(strong,nonatomic) NSString *tempImageString;
- @property(strong,nonatomic) AppDataObject* theDataObject;
- theAppDataObject.imageString = [tempImageString retain];
- // this the way too declare a protocal.
- // .h file
- @protocol TestProtocol <NSObject>
- -(void)testMyProtocolMethod:(NSString *)testvalue;
- @end
- @interface TestProtocolClass: NSObject
- {
- id <TestProtocol> delegate;
- }
- @property (nonatomic , assign) id <TestProtocol> delegate;
- /* synthesize in the .m file of this class*/
- @end
- //Now you have to use this protocol in any class where you want to use , Do like as:
- //let us suppose you want to use this protocal method in a class named "DemoProtocal".
- // .h file
- import "TestProtocol.h"
- @interface DemoProtocal <TestProtocol>{
- }
- @end
- //.m file
- #import "DemoProtocal.h"
- @implementation DemoProtocal
- - (id)init{
- TestProtocol *test = [[TestProtocol alloc]init];
- test.delegate = self;
- }
- -(void)testMyProtocolMethod:(NSString *)testvalue{
- // Do appropriate things.
- }
- @end
- //Declare a variable from where you want to set the value of the "AppDelegate Class".
- //in the yourclass.h file.
- AppDelegate/* this is the main class of the Application*/ *appDel;
- //and initialize it where you want to use or you can initialize at the init of the class.
- appDel = (AppDelegate *)[[UIApplication sharedApplication]delegate];
- // Then set the value.
- appDel.imageString = tempImageString;
Add Comment
Please, Sign In to add comment