Search Results

Search found 297 results on 12 pages for 'appdelegate'.

Page 1/12 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • NSInvalidArgumentException when updating WebView from AppDelegate

    - by H.Protagonist
    I had to do an update in my WebView from the Appdelegate.m I try it like this: [self performSelectorOnMainThread:@selector(loadWebViewWithContent:) withObject:requestObj waitUntilDone:NO]; The loadWebViewWithContent Method works great from ViewController.m, but not from the Appdelegate. I allready wrote this in my Appdelegate.h: -(void)loadWebViewWithContent:(NSURLRequest *)requestObj; Whats wrong? Please help me. I´m still a big Noob in IOS. Error: -[AppDelegate loadWebViewWithContent]: unrecognized selector sent to instance 0x1f86a5e0*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate loadWebViewWithContent]: unrecognized selector sent to instance 0x1f86a5e0'

    Read the article

  • Saving data in custom class via AppDelegate

    - by redspike
    I can't seem to save data to a custom instance object in my AppDelegate. My custom class is very simple and is as follows: Person.h ... @interface Person : NSObject { int _age; } - (void) setAge: (int) age; - (int) age; @end Person.m #import "Person.h" @implementation Person - (void) setAge:(int) age { _age = age; } - (int) age { return _age; } @end I then create an instance of Person in the AppDelegate class: AppDelegate.h @class Person; @interface AccuTaxAppDelegate : NSObject <UIApplicationDelegate> { ... Person *person; } ... @property (nonatomic, retain) Person *person; @end AppDelegate.m ... #import "Person.h" @implementation AccuTaxAppDelegate ... @synthesize person; - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; } - (void)applicationWillTerminate:(UIApplication *)application { // Save data if appropriate } #pragma mark - #pragma mark Memory management - (void)dealloc { [navigationController release]; [window release]; [person release]; [super dealloc]; } @end Finally, in my ViewController code I grab a handle on AppDelegate and then grab the person instance, but when I try to save the age it doesn't seem to work: MyViewController ... - (void)textFieldDidEndEditing:(UITextField *)textField { NSString *textAge = [textField text]; int age = [textAge intValue]; NSLog(@"Age from text field::%i", age); AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; Person *myPerson = (Person *)[appDelegate person]; NSLog(@"Age before setting: %i", [myPerson age]); [myPerson setAge:age]; NSLog(@"Age after setting: %i", [myPerson age]); [textAge release]; } ... The output of the above NSLogs are: [Session started at 2010-05-04 18:29:22 +0100.] 2010-05-04 18:29:28.260 AccuTax[16235:207] Age in text field:25 2010-05-04 18:29:28.262 AccuTax[16235:207] Age before setting: 0 2010-05-04 18:29:28.263 AccuTax[16235:207] Age after setting: 0 Any ideas why 'age' isn't being stored? I'm relatively new to Obj-C so please forgive me if I'm missing something very simple!

    Read the article

  • Setting an NSMutableArray in AppDelegate to be an NSMutableArray in

    - by aahrens
    What i'm trying to accomplish is to have an NSMutableArray defined in the AppDelegate. I then have two UIViewControllers. One view is responsible for displaying the array from the AppDelegate. The other view is used to add items to the array. So the array starts out to be empty. View1 doesn't display anything because the array is empty. The User goes to View2 and adds an item to the array in AppDelegate. Then when the user goes back to View1 it now displays one item. Here is how I'm trying to accomplish this @interface CalcAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; UITabBarController *tabBarController; NSMutableArray *globalClasses; } @property (nonatomic,retain) NSMutableArray *globalClasses; My other view In the viewDidload I set the array in my View to be the one in the AppDelegate. In an effort to retain values. allCourses = [[NSMutableArray alloc]init]; CalcAppDelegate *appDelegate = (CalcAppDelegate *)[[UIApplication sharedApplication] delegate]; allCourses = appDelegate.globalClasses; Then I would update my allCourses array by adding a new item. Then try to set the array in the AppDelegate to be equal to the modified one. CalcAppDelegate *appDel = (CalcAppDelegate *)[[UIApplication sharedApplication] delegate]; NSLog(@"Size before reset %d",[appDel.globalClasses count]); appDel.globalClasses = allCourses; NSLog(@"Size after reset %d",[appDel.globalClasses count]); What I'm seeing that's returned is 2 in the before, and 2 after. So it doesn't appear to be getting updated properly. Any suggestions?

    Read the article

  • iPhone: Using a NSMutableArry in the AppDelegate as a Global Variable

    - by aahrens
    What i'm trying to accomplish is to have an NSMutableArray defined in the AppDelegate. I then have two UIViewControllers. One view is responsible for displaying the array from the AppDelegate. The other view is used to add items to the array. So the array starts out to be empty. View1 doesn't display anything because the array is empty. The User goes to View2 and adds an item to the array in AppDelegate. Then when the user goes back to View1 it now displays one item. Here is how I'm trying to accomplish this @interface CalcAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; UITabBarController *tabBarController; NSMutableArray *globalClasses; } @property (nonatomic,retain) NSMutableArray *globalClasses; My other view In the viewDidload I set the array in my View to be the one in the AppDelegate. In an effort to retain values. allCourses = [[NSMutableArray alloc]init]; CalcAppDelegate *appDelegate = (CalcAppDelegate *)[[UIApplication sharedApplication] delegate]; allCourses = appDelegate.globalClasses; Then I would update my allCourses array by adding a new item. Then try to set the array in the AppDelegate to be equal to the modified one. CalcAppDelegate *appDel = (CalcAppDelegate *)[[UIApplication sharedApplication] delegate]; NSLog(@"Size before reset %d",[appDel.globalClasses count]); appDel.globalClasses = allCourses; NSLog(@"Size after reset %d",[appDel.globalClasses count]); What I'm seeing that's returned is 2 in the before, and 2 after. So it doesn't appear to be getting updated properly. Any suggestions?

    Read the article

  • Does the dealloc in Appdelegate calls or not?

    - by monish
    Hi guys, I the allocated arrays in the didFinishLaunching of my appdelegate.And I released those arrays in the dealloc of the appdelegate. My doubt here is does the dealloc of appdelegate calls?and does the arrays in the appdelegate releases or not? Anyone's help will be much appreciated. Thank you, Monish Kumar.

    Read the article

  • When my UIViewController accesses an NSArray in my AppDelegate from an IBAction it crashes the progr

    - by JasonClark
    I have a couple UIViewControllers that I am trying to access an array inside my AppDelegate. When I use an IBAction UIButton and in that method I access my AppDelegate my program dies silently. Nothing in output or the debugger, it just stops. If I run it several times I can see that it is failing to access the array properly. To investigate this problem I created a very basic app. In my AppDelegate.h I declared and set properties for the array #import <UIKit/UIKit.h> @class MyViewController; @interface MyAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MyViewController *viewController; NSArray *images; } @property (nonatomic, retain) NSArray *images; @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet MyViewController *viewController;` In the AppDelegate.m I synthesised and initialized the NSArray (Also made sure the images were added to the Resources folder). @synthesize images; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { images = [NSArray arrayWithObjects: [[NSBundle mainBundle] pathForResource:@"bamboo_nw" ofType:@"jpg"], ..... nil]; NSLog(@"init images size:%i",[images count]); [window addSubview:viewController.view]; [window makeKeyAndVisible]; return YES; } In my UIViewController.h I added class, imported header file, declared, and set properties for my AppDelegate pointer. #import <UIKit/UIKit.h> #import "MyAppDelegate.h" @class MyAppDelegate; @interface MyViewController : UIViewController { MyAppDelegate *mainDelegate; IBOutlet UIButton mybutton; } @property (nonatomic, retain) MyAppDelegate mainDelegate; @property (nonatomic, retain) UIButton *mybutton; -(IBAction) doSomething;` In my UIViewController.m I synthesize and assign my AppDelegate. I set up an IBAction that will log the same count of the NSArray from the AppDelegate. #import "MyViewController.h" #import "MyAppDelegate.h" @implementation MyViewController @synthesize mybutton; - (void)viewDidLoad { mainDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; NSLog(@"vdl images size:%i",[mainDelegate.images count]); [super viewDidLoad]; } -(IBAction) doSomething { NSLog(@"ds images size:%i",[mainDelegate.images count]); } I print the size of the NSArray in the AppDelegate when I create it, in the ViewController when I first assign my AppDelegate pointer, and then as a result of my IBAction. I find that everytime I hit the button the program dies. On the third time I hit the button, I saw that it ran my IBAction but printed my array size as 1 instead of 8. Am I missing something? Also, why don't I get stack traces or anything, the debugger just dies silently? Thanks in advance for any help! Debugger Console output for 3 runs: [Session started at 2010-05-10 06:21:32 -0700.] 2010-05-10 06:21:44.865 My[59695:207] init images size:8 2010-05-10 06:21:47.246 My[59695:207] vdl images size:8 [Session started at 2010-05-10 06:22:15 -0700.] 2010-05-10 06:22:18.920 My[59704:207] init images size:8 2010-05-10 06:22:19.043 My[59704:207] vdl images size:8 [Session started at 2010-05-10 06:22:23 -0700.] 2010-05-10 06:22:25.966 My[59707:207] init images size:8 2010-05-10 06:22:26.017 My[59707:207] vdl images size:8 2010-05-10 06:22:27.814 My[59707:207] ds images size:1

    Read the article

  • iOS Facebook SDK: FBRequestDelegate only works on AppDelegate??

    - by RMR
    Hi guys, I want to encapsulate all my Facebook interactions within a FacebookFacade class to keep things clean and tidy. I have an instance of the iOS SDK Facebook class within my FacebookFacade. My problem is that when I make a Graph API call within the facade, such as: [self.facebook requestWithGraphPath:@"me" andDelegate:self]; the only method of FBRequestDelegate that gets called is requestLoading: and nothing else. I have tried putting similar code in other places, like in controllers and other models, and there too not all of the FBRequestDelegate methods get called, only requestLoading:. In fact the only way I can get the other FBRequestDelegate methods to be called is to put all my Facebook logic in the AppDelegate and make my AppDelegate the FBRequestDelegate. Why is this the case? Am I missing something here? I definitely do not want to use the AppDelegate as my FBRequestDelegate as I don't want to confuse the purpose of the AppDelegate. Thanks.

    Read the article

  • AppDelegate, RootViewController, and UIApplication

    - by guy8214
    Hi Guys I am trying to figure out the relationship between the appdelegate, RootViewControoler, and UIApplication. Here is what I kinda have figured out so far: When starting your application up, main.m gets loaded. From here, your MainWindow.xib gets loaded. In your MainWindow.xib, your File's Owner is of type UIApplication. You set your UIApplication's delegate to your AppDelegate. In your AppDelegate's source code, you can set your RootViewController to be the first view shown. Is this right? What prompts AppDelegate to initially run it's - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { } method?

    Read the article

  • Call AppDelegate Method from Class

    - by golfromeo
    Basically, I need to call a method in my AppDelegate from one of my view controller classes. Currently, I'm doing the following: myAppDelegate *appDelegate = (myAppDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate doMethod]; And including the myAppDelegate.h at the top of the .m file of the class: #import "myAppDelegate.h" When I run it, everything works... But I get the following warning: warning 'myAppDelegate' may not respond to '-doMethod' Is there another way that I should reference the app delegate? Thanks for any help in advance.

    Read the article

  • Using Kal calendar without doing the initialization (and so on) in the AppDelegate

    - by testing
    I'm using the Kal calendar. For the code shown below I'm referring to the Holiday example. In this example the allocation and initialization of Kal is done in the applicationDidFinishLaunching in the AppDelegate. The UITableViewDelegate protocol (e.g. didSelectRowAtIndexPath) is also positioned in the AppDelegate class. The AppDelegate: #import "HolidayAppDelegate.h" #import "HolidaySqliteDataSource.h" #import "HolidaysDetailViewController.h" ## Heading ###import "Kal.h" @implementation HolidayAppDelegate @synthesize window; - (void)applicationDidFinishLaunching:(UIApplication *)application { kal = [[KalViewController alloc] init]; kal.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Today" style:UIBarButtonItemStyleBordered target:self action:@selector(showAndSelectToday)] autorelease]; kal.delegate = self; dataSource = [[HolidaySqliteDataSource alloc] init]; kal.dataSource = dataSource; // Setup the navigation stack and display it. navController = [[UINavigationController alloc] initWithRootViewController:kal]; [window addSubview:navController.view]; [window makeKeyAndVisible]; } // Action handler for the navigation bar's right bar button item. - (void)showAndSelectToday { [kal showAndSelectDate:[NSDate date]]; } #pragma mark UITableViewDelegate protocol conformance // Display a details screen for the selected holiday/row. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { Holiday *holiday = [dataSource holidayAtIndexPath:indexPath]; HolidaysDetailViewController *vc = [[[HolidaysDetailViewController alloc] initWithHoliday:holiday] autorelease]; [navController pushViewController:vc animated:YES]; } #pragma mark - - (void)dealloc { [kal release]; [dataSource release]; [window release]; [navController release]; [super dealloc]; } @end I don't want to put this into the AppDelegate, because there could be some overlapping code with other views. It should be a separate "component" which I can call and put on the stack. In my navigation based project I have a main view, the RootViewController. From there I want to push the Kal view on the stack. Currently I'm pushing an additional ViewController on the stack. In the viewWillAppear method from this ViewController I do the things shown in the code above. The following problems appear: Navigation back has to be done two times (one for the Kal calendar, one for my created view) Navigation to my main view is not possible anymore In the moment I don't know where to put this code. So the question is where to put the methods for allocation/initialization as well as the methods for the UITableViewDelegate protocol.

    Read the article

  • DeviceOrientation Check in AppDelegate

    - by ludo
    Hi, I created a view in the AppDelegate, that I add to the window like this:[window addSubview:myView]; I wanna be able to check for the device orientation everytime I come back to this view, so I can make some modifications to it. How can I do that in the appDelegate?

    Read the article

  • How to create Dictionary object in AppDelegate to access objectkey in another ViewController

    - by TechFusion
    Hello, I have created Window Based application and tab bar controller as root controller. My objective is to store Text Field data values in one tab bar VC and will be accessible and editable by other VC and also retrievable when application start. I am looking to use NSDictionary class in AppDelegate so that I can access stroed Data Values with keys. //TestAppDelegate.h @interface { ..... .... NSDictionary *Data; } @property (nonatomic, retain) NSDictionary *Data; //TestAppDelegate.m #import "TestAppDelegate.h" NSString *kNamekey =@"Namekey"; NSString *kUserIDkey =@"UserIDkey"; NSString *kPasswordkey =@"Passwordkey"; @implemetation TestAppDelegate @synthesize Data; -(void)applicationDidFinishLaunching:(UIApplication)application { NSString *NameDefault; NSString *UserIDdefault; NSString *Passworddefault; NSString *testvalue = [[NSUserDefaults standardUserDefaults] stringForKey: kNamekey]; if(testvalue == nil) { NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: NameDefault, kNamekey, UserIdefault kUserIDkey, Passwordefault kPasswordkey, nil]; self.Data = appDefaults; [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; [[NSUserDefaults standardUserDefaults] synchronize]; } else { } } Here ViewController is ViewController of Navigation Controller which is attached with one tab bar.. I have attached xib file with ViewController //ViewController.h @interface IBOutlet UITextField *Name; IBOutlet UITextField *UserId; IBOutlet UITextField *Password; } @property(retain,nonatomic) IBOutlet UITextField *Name @property(retain,nonatomic) IBOutlet UITextField *UserId; @property(retain,nonatomic) IBOutlet UITextField *Password; -(IBAction)Save:(id)sender; @end Here in ViewController.m I want to store Text Field input data with key which are defined in AppDelegate. I have linked Save Barbutton with action. Here I am not getting how to access NSDictionary class with object and keys in ViewController. //ViewController.m -(IBAction)Save:(id)sender{ TestAppDelegate *appDelegate = (TestAppDelegate*)[[UIApplication sharedApplication] delegate]; //Here how to access knamekey here to set object(Name.test) value with key } Please guide me about this. Thanks,

    Read the article

  • NSNotification postNotificationName in AppDelegate but NSNotificationCenter in ViewController?

    - by James Testa
    I can't get the selector method, receiveChatText, in the NSNotificationCenter to execute and I am wondering if the problem is because the NSNotification postNotificationName is in AppDelegate.m but NSNotificationCenter is in ViewController.m? I.E. can the postNotificationName know that the NSNotificationCenter is in another viewController file or is that something I need to tell it? In a viewController.m I have -(id)init { self = [super init]; if(self){ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveChatText:) name:ChatMessageReceived object:nil]; return self; } - (void)receiveChatText:(NSNotification *)note { NSLog(@"received chat text"); } and in the top level AppDelegate.m file I have the following: -(void) didReceiveMessage { [[NSNotificationCenter defaultCenter] postNotificationName:ChatMessageReceived object:nil userInfo:nil]; } Any ideas what could stop receiveChatText from being executed when didReceiveMessage is called?

    Read the article

  • How much should the AppDelegate do?

    - by Rudiger
    I'm designing quite a large App and on startup it will create sessions with a few different servers. As they are creating a session which is used across all parts of the app its something I thought would be best in App Delegate. But the problem is I need the session progress to be represented on the screen. I plan to have a UIToolBar at the bottom of the main menu which I don't want to cover with the progress bar but cover the UIView above it.So the way I see it I could do it a few different ways. 1) Have the App Delegate establish the sessions and report the progress to the main menu class so it can represent it in the progress bar (will I have any issues doing this if the sessions are created in a separate thread?), 2) have the App delegate display the main menu (UIView with a bunch of buttons and UIToolBar) and have it track and display the progress (I have never displayed anything in the App Delegate but assume you can do this but its not recommended) or 3) have the App Delegate just push the main menu and have the mainMenu class create the sessions and display the progress bar. 4) I think the other way to do it is to create the sessions in a delegate class and have the delegate set to mainMenu rather than self (AppDelegate), although I've never used anything other then self so not sure if this will work or if I will be able to close the thread (through calling super maybe?) as its running in the AppDelegate rather than the delegate of the class. As I've kinda said before the sessions are being created in a class in a separate thread so it wont lock the UI and I think the best way is the first but am I going to have issues having it running in a separate thread, reporting back to the app delegate and then sending that message to the mainMenu view? I hope that all makes sense, let me know if you need any further clarification. Any information is appreciated Cheers,

    Read the article

  • No visible @interface for 'AppDelegate' declares the selector

    - by coolhongly
    I'm now writing a registration screen before my tabBar shows up. My idea is to show my registration screen through this method (no dismiss function for now): - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. Register *registerView = [[Register alloc] initWithNibName:nil bundle:nil]; [self presentModalViewController:registerView animated:YES]; return YES; } Which is in AppDelegate.m Unfortunately it doesn't work. Could you help me solve this please?

    Read the article

  • Using object instead of AppDelegate for Outlets & Actions?

    - by Driss Zouak
    In all the MonoTouch examples I have seen everyone is using outlets and actions on AppDelegate, yet when I've been through some objective-C webcasts I see people using an Object they drag onto XIB in Interface Builder and using that (Seems a lot cleaner). Is there just not a way to reference any Objects like that that we create? Is there a particular way to access it? Any advice would be appreciated, thanks

    Read the article

  • NSMutableArray in appdelegate - EXEC_BAD_ACCESS

    - by Tejaswi Yerukalapudi
    Hi, I'm trying to use a global array in the appdelegate as a quick fix for a demo I'm building. The relevant code for this .h file has the declaration { NSMutableArray *trnEntered; } @property (nonatomic, retain) NSMutableArray *trnEntered .m file has the following code - trnEntered = [[NSMutableArray alloc] init]; NSLog(@"%@",[trnEntered count]); // prints null. [trnEntered addObject:@"1"]; NSLog(@"%@",[trnEntered count]); // exec bad access. Not sure where I'm going wrong here. Looks fairly straight forward. Thanks for the help in advance, Teja.

    Read the article

  • Trouble setting FIrst view controller which will appear on App Startup

    - by Matte.Car
    I'm setting setting FIrst view controller which will appear on my App Startup. It should appear an UIView first time as a tutorial and, from second time, another standard view. In AppDelegate I wrote this: #import "AppDelegate.h" #import "TabBarController.h" #import "TutorialController.h" @implementation AppDelegate TabBarController * viewControllerStandard; // standard view TutorialController * viewControllerFirst; // tutorial view @synthesize window; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if ([@"1" isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"Startup"]]) { window.rootViewController = viewControllerStandard; } else { window.rootViewController = viewControllerFirst; } [window makeKeyAndVisible]; return YES; } It doesn't return any alert but, launching app, after splashscreen, it appear only a black screen. Without that codes everything works fine. What could be wrong? Thank you!

    Read the article

  • How is an AppDelegate instanciated?

    - by pwny
    I have an iOS application for which I want to create a ViewController programmatically. I started an empty XCode project and modified the main method so it looks like this int main(int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, @"MyAppDelegate_iPad"); [pool release]; return retVal; } The app is a Universal Application, MyAppDelegate_iPad is a subclass of MyAppDelegate, which is a subclass of NSObject <UIApplicationDelegate>. My problem is that the applicationDidFinishLoading method I've overridden in MyAppDelegate_iPad is never called (break point on the first line never hits). The method looks like this -(void) applicationDidFinishLaunching:(UIApplication *)application { window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; if(!window) { [self release]; return; } window.backgroundColor = [UIColor whiteColor]; rootController = [[MyViewController alloc] init]; [window addSubview:rootController.view]; [window makeKeyAndVisible]; [window layoutSubviews]; } I removed the line to link to a nib file from my plist file (I used to get the default "My Universal app on iPad" white screen) and now all that is displayed is a black screen. applicationDidFinishLoading is still not being called. Am I doing something wrong? How should I properly create my AppDelegate instance?

    Read the article

  • Having problem loading data from AppDelegate using UITableView into a flip view, loads first view bu

    - by Ms. Ryann
    AppDelegate: @implementation Ripe_ProduceGuideAppDelegate -(void)applicationDidFinishLaunching:(UIApplication *)application { Greens *apricot = [[Greens alloc] init]; apricot.produceName = @"Apricot"; apricot.produceSight = @"Deep orange or yellow orange in appearance, may have red tinge, no marks or bruises. "; apricot.produceTouch = @"Firm to touch and give to gentle pressure, plump."; apricot.produceSmell = @"Should be Fragrant"; apricot.produceHtoP = @"raw, salads, baked, sauces, glazes, desserts, poached, stuffing."; apricot.produceStore = @"Not ripe: place in brown paper bag, at room temperature and out of direct sunlight, close bag for 2 - 3 days. Last for a week. Warning: Only refrigerate ripe apricots."; apricot.produceBest = @"Spring & Summer"; apricot.producePic = [UIImage imageNamed:@"apricot.jpg"]; Greens *artichoke = [[Greens alloc] init]; artichoke.produceName = @"Artichoke"; artichoke.produceSight = @"Slightly glossy dark green color and sheen, tight petals that are not be too open, no marks, no brown petals or dried out look. Stem should not be dark brown or black."; artichoke.produceTouch = @"No soft spots"; artichoke.produceSmell = @" Should not smell"; artichoke.produceHtoP = @"steam, boil, grill, saute, soups"; artichoke.produceStore = @"Stand up in vase of cold water, keeps for 2 -3 days. Or, place in refrigerator loose without plastic bag. May be frozen, if cooked but not raw."; artichoke.produceBest = @"Spring"; artichoke.producePic = [UIImage imageNamed:@"artichoke.jpg"]; self.produce = [[NSMutableArray alloc] initWithObjects:apricot, artichoke, nil]; [apricot release]; [artichoke release]; FirstView: @implementation ProduceView -(id)initWithIndexPath: (NSIndexPath *)indexPath { if (self == [super init] ){ index = indexPath; } return self; } -(void)viewDidLoad { Ripe_ProduceGuideAppDelegate *delegate = (Ripe_ProduceGuideAppDelegate *) [[UIApplication sharedApplication] delegate]; Greens *thisProduce = [delegate.produce objectAtIndex:index.row]; self.title = thisProduce.produceName; sightView.text = thisProduce.produceSight; touchView.text = thisProduce.produceTouch; smellView.text = thisProduce.produceSmell; picView.image = thisProduce.producePic; } FlipView: @implementation FlipsideViewController @synthesize flipDelegate; -(id)initWithIndexPath: (NSIndexPath *)indexPath { if ( self == [super init]) { index = indexPath; } return self; } -(void)viewDidLoad { Ripe_ProduceGuideAppDelegate *delegate = (Ripe_ProduceGuideAppDelegate *) [[UIApplication sharedApplication] delegate]; Greens*thisProduce = [delegate.produce objectAtIndex:index.row]; self.title = thisProduce.produceName; bestView.text = thisProduce.produceBest; htopView.text = thisProduce.produceHtoP; storeView.text = thisProduce.produceStore; picView.image = thisProduce.producePic; } *the app works, the flip view for Artichoke shows the information for Apricot. Been working on it for two days. I have been working with iPhone apps for two months now and would very much appreciate any assistance with this problem. Thank you very much.

    Read the article

  • AppDelegate viewController memory leak?

    - by fuzzygoat
    I am just curious with regards to the correct way to create a view controller programatically. When I compile this code with the static analyser I get a leak (as you would expect) from the alloc. Should I just leave it as it needs to stay until the app exits anyways, or is there a cleaner way? - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSLog(@"UIApplication application:"); RectViewController *myController = [[RectViewController alloc] init]; [window addSubview:[myController view]]; [window makeKeyAndVisible]; return YES; } cheers Gary

    Read the article

  • Loading 2 Singletons With Dependencies when an app is opened (appDelegate / appDidBecomeActive) iPhone SDK

    - by taber
    I'm trying to load two standard-issue style singletons: http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html when my iPhone app is loaded. Here's my code: - (void) applicationDidFinishLaunching:(UIApplication *)application { // first, restore user prefs [AppState loadState]; // then, initialize the camera [[CameraModule sharedCameraModule] initCamera]; } My "camera module" has code that checks a property of the AppState singleton. But I think what's happening is a race condition where the camera module singleton is trying to access the AppState property while it's in the middle of being initialized (so the property is nil, and it's re-initializing AppState). I'd really like to keep these separate, instead of just throwing one (or both) into the App Delegate. Has anyone else seen something like this? What kind of workaround did you use, or what would you suggest? Thanks in advance! Here's the loadState method: + (void)loadState { @synchronized([AppState class]) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *file = [documentsDirectory stringByAppendingPathComponent:@"prefs.archive"]; Boolean saveFileExists = [[NSFileManager defaultManager] fileExistsAtPath:file]; if(saveFileExists) { sharedAppState = [[NSKeyedUnarchiver unarchiveObjectWithFile:file] retain]; } else { [AppState sharedAppState]; } } }

    Read the article

  • iphone app hangs in AppDelegate (?)

    - by d_CFO
    No nib/IB, so I've inserted "myAppDelegate" in main and deleted the reference to main.xib in info.plist. Debug continues nicely through all five tab controllers; they seem to have gotten properly loaded into the nav controller. In fact, control passes out of the last "}" in applicationDidFinishLaunching. But there was no (visible) response back at [window addSubview:[tabBarController view]]; and [window makeKeyAndVisible]; statements, much less to the loadView within the first tab (program execution never gets there). The last line is, UIApplication _performInitializationWithURL:sourceBundleID:]. I missed a step? I executed a step improperly?

    Read the article

  • App delegate doesn't work after starting using Storyboards -iOS

    - by user968173
    I have a small problem with my game.. I wanna stop my game whenever it's interrupted. My stopGame method was working when I called it in applicationWillResignActive when I was using xib files. When I changed it to storyboards, it stopped working.. applicationWillResignActive still works with storyboards and my stopGame method is called, but for some reason, my game does not stop.. Has someone faced a problem like this? And possible solutions please.. Thanks in advance..

    Read the article

  • Can I include a NSUserDefault password test in AppDelegate to load a loginView?

    - by Michael Robinson
    I have a name and password in NSUserDefaults for login. I want to place a test in my AppDelegate.m class to test for presence and load a login/signup loginView.xib modally if there is no password or name stored in the app. Here is the pulling of the defaults: -(void)refreshFields { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; usernameLabel.text = [defaults objectForKey:kUsernameKey]; passwordLabel.text = [defaults objectForKey:kPasswordKey]; Here is the tabcontroller loading part: - (void)applicationDidFinishLaunching:(UIApplication *)application { firstTab = [[FirstTab alloc] initWithStyle:UITableViewStylePlain]; UINavigationController *firstNavigationController = [[UINavigationController alloc] initWithRootViewController:firstTab]; [firstTab release]; secondTab = // EDITED FOR SPACE thirdTab = // EDITED FOR SPACE tabBarController = [[UITabBarController alloc] init]; tabBarController.viewControllers = [NSArray arrayWithObjects:firstNavigationController, secondNavigationController, thirdNavigationController, nil]; [window addSubview:tabBarController.view]; [firstNavigationController release]; [secondNavigationController release]; [thirdNavigationController release]; [self logout]; [window makeKeyAndVisible]; Here is where the loginView.xib loads automatically: - (void)logout { loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginView" bundle:nil]; UINavigationController *loginNavigationController = [[UINavigationController alloc] initWithRootViewController:loginViewController]; [loginViewController release]; [tabBarController presentModalViewController:loginNavigationController animated:YES]; [loginNavigationController release]; } I want to replace the above autoload with a test similar to below (that works) using IF-ELSE - (void)logout { if ([usernameLabel.text length] == 0 || [passwordLabel.text length] == 0) { loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginView" bundle:nil]; UINavigationController *loginNavigationController = [[UINavigationController alloc] initWithRootViewController:loginViewController]; [loginViewController release]; [tabBarController presentModalViewController:loginNavigationController animated:YES]; [loginNavigationController release]; }else { [window addSubview:tabBarController.view];} Thanks in advance, I'm totally lost on this.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >