Search Results

Search found 396 results on 16 pages for 'dealloc'.

Page 8/16 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • How do I call a variable from another class?

    - by squeezemylime
    I have a class called 'Constants' that I am storing a String variable in. This class contains a few global variables used in my app. I want to be able to reference this class and call the variable (called profileId) in other Views of my app. I looked around and found a few examples, but am not sure how to do this. Currently my setup is: Constants.h @interface Constants : UIViewController { NSString *profileId; } @property (nonatomic, retain) NSString *profileId; @end Constants.m #import "Constants.h" @implementation Constants @synthesize profileId; - (void)dealloc { [profileId release]; [super dealloc]; } And I am trying to call the variable profileId in a new View via this way: NewView.h file @class Constants; NewView.m file NSLog(@"ProfileId is:", [myConstants profileId]); Is there something I'm missing? It is coming up null, even though I am properly storing a value in it in another function via this way: Constants *Constant; Constant = [[Constants alloc] init]; Constant.profileId = userId;

    Read the article

  • Obj-C Sending Messages Between Classes

    - by user544359
    I'm a newbie in iPhone Programming. I'm trying to send a message from one view controller to another. The idea is that viewControllerA takes information from the user and sends it to viewControllerB. viewControllerB is then supposed to display the information in a label. viewControllerA.h #import <UIKit/UIKit.h> @interface viewControllerA : UIViewController { int num; } -(IBAction)do; @end viewControllerA.m #import "viewControllerA.h" #import "viewControllerB.h" @implementation viewControllerA - (IBAction)do { //initializing int for example num = 2; viewControllerB *viewB = [[viewControllerB alloc] init]; [viewB display:num]; [viewB release]; //viewA is presented as a ModalViewController, so it dismisses itself to return to the //original view, i know it is not efficient [self dismissModalViewControllerAnimated:YES]; } - (void)dealloc { [super dealloc]; } @end viewControllerB.h #import <UIKit/UIKit.h> @interface viewControllerB : UIViewController { IBOutlet UILabel *label; } - (IBAction)openA; - (void)display:(NSInteger)myNum; @end viewControllerB.m #import "viewControllerB.h" #import "viewControllerA.h" @implementation viewControllerB - (IBAction)openA { //presents viewControllerA when a button is pressed viewControllerA *viewA = [[viewControllerA alloc] init]; [self presentModalViewController:viewA animated:YES]; } - (void)display:(NSInteger)myNum { NSLog(@"YES"); [label setText:[NSString stringWithFormat:@"%d", myNum]]; } @end YES is logged successfully, but the label's text does not change. I have made sure that all of my connections in Interface Builder are correct, in fact there are other (IBAction) methods in my program that change the text of this very label, and all of those other methods work perfectly... Any ideas, guys? You don't need to give me a full solution, any bits of information will help. Thanks.

    Read the article

  • Why do I have memory problems?

    - by Tattat
    I got this error from XCode: objc[8422]: FREED(id): message release sent to freed object=0x3b120c0 I googled and find that is related to the memory. But I don't know which line of code I go wrong, any ideas? After I launch my app in simulator, it prompts a second, than, no other error except the error above. @implementation MyAppDelegate @synthesize window; @synthesize viewController; - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; [self changeScene:[MainGameMenuScene class]]; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } - (void) changeScene: (Class) scene { BOOL animateTransition = true; if(animateTransition){ [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES]; //does nothing without this line. } if( viewController.view != nil ) { [viewController.view removeFromSuperview]; //remove view from window's subviews. [viewController.view release]; //release gamestate } viewController.view = [[scene alloc] initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT) andManager:self]; //now set our view as visible [window addSubview:viewController.view]; [window makeKeyAndVisible]; if(animateTransition){ [UIView commitAnimations]; } }

    Read the article

  • How do I display core data on second view controller?

    - by jon
    I am working on my first core data iPhone application. I am using a navigation controller, and the root view controller displays 4 rows. Clicking the first row takes me to a second table view controller. However, when I click the back button, repeat the row tap, click the back button again, and tap the row a third time, I get an error. I have been researching this for a week with no success. I can reproduce the error easily: Create a new Navigation-based Application, use Core Data for storage, call it MyTest which creates MyTestAppDelegate and RootViewController. Add new UIViewController subclass, with UITableViewController and xib, call it ListViewController. Copy code from RootViewController.h and .m to ListViewController.h and .m., changing the file names appropriately. To simplify the code, I removed the trailing “_” from all variables. In RootViewController, I added #import ListViewController.h, set up an array to display 4 rows and navigate to ListViewController when clicking the first row. In ListViewController.m, I added #import MyTestAppDelegate.h” and the following code: - (void)viewDidLoad { [super viewDidLoad]; if (managedObjectContext == nil) { managedObjectContext = [(MyTestAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; } .. } The sequence that causes the error is tap row, return, tap row, return, tap row - error. managedObjectContext is synthesized for the third time. I appreciate your patience and your help, as this makes no sense to me. ADDENDUM: I may have a partial solution. http://www.iphonedevsdk.com/forum/iphone-sdk-development/41688-accessing-app-delegates-managed-object-context.html If I do not release the managedObjectContext in the .m file, the error goes away. Is that ok or will that cause me issues? - (void)dealloc { [fetchedResultsController release]; // [managedObjectContext release]; [super dealloc]; } ADDENDUM 2: See solution below. Sorry for the formatting issues - this was my first post.

    Read the article

  • How to create a timer the right way?

    - by mystify
    I always have an class which needs to set up a timer for as long as the object is alive. Typically an UIView which does some animation. Now the problem: If I strongly reference the NSTimer I create and invalidate and release the timer in -dealloc, the timer is never invalidated or released because -dealloc is never called, since the run loop maintains a strong reference to the target. So what can I do? If I cant hold a strong ref to the timer object, this is also bad because maybe I need a ref to it to be able to stop it. And a weak ref on a object is not good, because maybe i'm gonna access it when it's gone. So better have a retain on what I want to keep around. How are you guys solving this? must the superview create the timer? is that better? or should i really just make a weak ref on it and keep in mind that the run loop holds a strong ref on my timer for me, as long as it's not invalidated?

    Read the article

  • regular expression to read the string between <title> and </title>

    - by user262325
    Hello every one I hope to read the contents between and in a html string. I think it should be in objective-c @"<title([\\s\\S]*)</title>" below are the codes that rewrited for regular expression //source of NSStringCategory.h #import <Foundation/Foundation.h> #import <regex.h> @interface NSStringCategory:NSObject { regex_t preg; } -(id)initWithPattern:(NSString *)pattern options:(int)options; -(void)dealloc; -(BOOL)matchesString:(NSString *)string; -(NSString *)matchedSubstringOfString:(NSString *)string; -(NSArray *)capturedSubstringsOfString:(NSString *)string; +(NSStringCategory *)regexWithPattern:(NSString *)pattern options:(int)options; +(NSStringCategory *)regexWithPattern:(NSString *)pattern; +(NSString *)null; +(void)initialize; @end @interface NSString (NSStringCategory) -(BOOL)matchedByPattern:(NSString *)pattern options:(int)options; -(BOOL)matchedByPattern:(NSString *)pattern; -(NSString *)substringMatchedByPattern:(NSString *)pattern options:(int)options; -(NSString *)substringMatchedByPattern:(NSString *)pattern; -(NSArray *)substringsCapturedByPattern:(NSString *)pattern options:(int)options; -(NSArray *)substringsCapturedByPattern:(NSString *)pattern; -(NSString *)escapedPattern; @end and .m file #import "NSStringCategory.h" static NSString *nullstring=nil; @implementation NSStringCategory -(id)initWithPattern:(NSString *)pattern options:(int)options { if(self=[super init]) { int err=regcomp(&preg,[pattern UTF8String],options|REG_EXTENDED); if(err) { char errbuf[256]; regerror(err,&preg,errbuf,sizeof(errbuf)); [NSException raise:@"CSRegexException" format:@"Could not compile regex \"%@\": %s",pattern,errbuf]; } } return self; } -(void)dealloc { regfree(&preg); [super dealloc]; } -(BOOL)matchesString:(NSString *)string { if(regexec(&preg,[string UTF8String],0,NULL,0)==0) return YES; return NO; } -(NSString *)matchedSubstringOfString:(NSString *)string { const char *cstr=[string UTF8String]; regmatch_t match; if(regexec(&preg,cstr,1,&match,0)==0) { return [[[NSString alloc] initWithBytes:cstr+match.rm_so length:match.rm_eo-match.rm_so encoding:NSUTF8StringEncoding] autorelease]; } return nil; } -(NSArray *)capturedSubstringsOfString:(NSString *)string { const char *cstr=[string UTF8String]; int num=preg.re_nsub+1; regmatch_t *matches=calloc(sizeof(regmatch_t),num); if(regexec(&preg,cstr,num,matches,0)==0) { NSMutableArray *array=[NSMutableArray arrayWithCapacity:num]; int i; for(i=0;i<num;i++) { NSString *str; if(matches[i].rm_so==-1&&matches[i].rm_eo==-1) str=nullstring; else str=[[[NSString alloc] initWithBytes:cstr+matches[i].rm_so length:matches[i].rm_eo-matches[i].rm_so encoding:NSUTF8StringEncoding] autorelease]; [array addObject:str]; } free(matches); return [NSArray arrayWithArray:array]; } free(matches); return nil; } +(NSStringCategory *)regexWithPattern:(NSString *)pattern options:(int)options { return [[[NSStringCategory alloc] initWithPattern:pattern options:options] autorelease]; } +(NSStringCategory *)regexWithPattern:(NSString *)pattern { return [[[NSStringCategory alloc] initWithPattern:pattern options:0] autorelease]; } +(NSString *)null { return nullstring; } +(void)initialize { if(!nullstring) nullstring=[[NSString alloc] initWithString:@""]; } @end @implementation NSString (NSStringCategory) -(BOOL)matchedByPattern:(NSString *)pattern options:(int)options { NSStringCategory *re=[NSStringCategory regexWithPattern:pattern options:options|REG_NOSUB]; return [re matchesString:self]; } -(BOOL)matchedByPattern:(NSString *)pattern { return [self matchedByPattern:pattern options:0]; } -(NSString *)substringMatchedByPattern:(NSString *)pattern options:(int)options { NSStringCategory *re=[NSStringCategory regexWithPattern:pattern options:options]; return [re matchedSubstringOfString:self]; } -(NSString *)substringMatchedByPattern:(NSString *)pattern { return [self substringMatchedByPattern:pattern options:0]; } -(NSArray *)substringsCapturedByPattern:(NSString *)pattern options:(int)options { NSStringCategory *re=[NSStringCategory regexWithPattern:pattern options:options]; return [re capturedSubstringsOfString:self]; } -(NSArray *)substringsCapturedByPattern:(NSString *)pattern { return [self substringsCapturedByPattern:pattern options:0]; } -(NSString *)escapedPattern { int len=[self length]; NSMutableString *escaped=[NSMutableString stringWithCapacity:len]; for(int i=0;i<len;i++) { unichar c=[self characterAtIndex:i]; if(c=='^'||c=='.'||c=='['||c=='$'||c=='('||c==')' ||c=='|'||c=='*'||c=='+'||c=='?'||c=='{'||c=='\\') [escaped appendFormat:@"\\%C",c]; else [escaped appendFormat:@"%C",c]; } return [NSString stringWithString:escaped]; } @end I use the codes below to get the string between "" and "" NSStringCategory *a=[[NSStringCategory alloc] initWithPattern:@"<title([\s\S]*)</title>" options:0];// Unfortunately [a matchedSubstringOfString:response]] always returns nil I do not if the regular expression is wrong or any other reason. Welcome any comment Thanks interdev

    Read the article

  • Best memory allocation strategy for iOS ?

    - by Mr.Gando
    Hey guys, I'm debating myself about memory allocation on iOS. I write most of my code in C++ and I really like using ObjectPools, FreeLists, etc. In order to pre-allocate a lot of the stuff that I'll be constantly "alloc/dealloc" during the course of my game, ( like particles, game entities, etc ). Still on iOS, it's not like we are developing for a console like PSP, where I can know for fact that I'll get a fixed amount of memory. iOS , will issue "memory warnings" when the system needs memory. Does anyone have some suggestions about this ? Is it too serious since the new iPod touch/iPhone 4 are carrying more RAM ? or it's still a big concern ? Thanks!

    Read the article

  • iphone: Help with AudioToolbox Leak: Stack trace/code included here...

    - by editor guy
    Part of this app is a "Scream" button that plays random screams from cast members of a TV show. I have to bang on the app quite a while to see a memory leak in Instruments, but it's there, occasionally coming up (every 45 seconds to 2 minutes.) The leak is 3.50kb when it occurs. Haven't been able to crack it for several hours. Any help appreciated. Instruments says this is the offending code line: [appSoundPlayer play]; that's linked to from line 9 of the below stack trace: 0 libSystem.B.dylib malloc 1 libSystem.B.dylib pthread_create 2 AudioToolbox CAPThread::Start() 3 AudioToolbox GenericRunLoopThread::Start() 4 AudioToolbox AudioQueueNew(bool, AudioStreamBasicDescription const*, TCACallback const&, CACallbackTarget const&, unsigned long, OpaqueAudioQueue*) 5 AudioToolbox AudioQueueNewOutput 6 AVFoundation allocAudioQueue(AVAudioPlayer, AudioPlayerImpl*) 7 AVFoundation prepareToPlayQueue(AVAudioPlayer*, AudioPlayerImpl*) 8 AVFoundation -[AVAudioPlayer prepareToPlay] 9 Scream Queens -[ScreamViewController scream:] /Users/laptop2/Desktop/ScreamQueens Versions/ScreamQueens25/Scream Queens/Classes/../ScreamViewController.m:210 10 CoreFoundation -[NSObject performSelector:withObject:withObject:] 11 UIKit -[UIApplication sendAction:to:from:forEvent:] 12 UIKit -[UIApplication sendAction:toTarget:fromSender:forEvent:] 13 UIKit -[UIControl sendAction:to:forEvent:] 14 UIKit -[UIControl(Internal) _sendActionsForEvents:withEvent:] 15 UIKit -[UIControl touchesEnded:withEvent:] 16 UIKit -[UIWindow _sendTouchesForEvent:] 17 UIKit -[UIWindow sendEvent:] 18 UIKit -[UIApplication sendEvent:] 19 UIKit _UIApplicationHandleEvent 20 GraphicsServices PurpleEventCallback 21 CoreFoundation CFRunLoopRunSpecific 22 CoreFoundation CFRunLoopRunInMode 23 GraphicsServices GSEventRunModal 24 UIKit -[UIApplication _run] 25 UIKit UIApplicationMain 26 Scream Queens main /Users/laptop2/Desktop/ScreamQueens Versions/ScreamQueens25/Scream Queens/main.m:14 27 Scream Queens start Here's .h: #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> #import <MediaPlayer/MediaPlayer.h> #import <AudioToolbox/AudioToolbox.h> #import <MessageUI/MessageUI.h> #import <MessageUI/MFMailComposeViewController.h> @interface ScreamViewController : UIViewController <UIApplicationDelegate, AVAudioPlayerDelegate, MFMailComposeViewControllerDelegate> { //AudioPlayer related AVAudioPlayer *appSoundPlayer; NSURL *soundFileURL; BOOL interruptedOnPlayback; BOOL playing; //Scream button related IBOutlet UIButton *screamButton; int currentScreamIndex; NSString *currentScream; NSMutableArray *screams; NSMutableArray *personScreaming; NSMutableArray *photoArray; int currentSayingsIndex; NSString *currentButtonSaying; NSMutableArray *funnyButtonSayings; IBOutlet UILabel *funnyButtonSayingsLabel; IBOutlet UILabel *personScreamingField; IBOutlet UIImageView *personScreamingImage; //Mailing the scream related IBOutlet UILabel *mailStatusMessage; IBOutlet UIButton *shareButton; } //AudioPlayer related @property (nonatomic, retain) AVAudioPlayer *appSoundPlayer; @property (nonatomic, retain) NSURL *soundFileURL; @property (readwrite) BOOL interruptedOnPlayback; @property (readwrite) BOOL playing; //Scream button related @property (nonatomic, retain) UIButton *screamButton; @property (nonatomic, retain) NSMutableArray *screams; @property (nonatomic, retain) NSMutableArray *personScreaming; @property (nonatomic, retain) NSMutableArray *photoArray; @property (nonatomic, retain) UILabel *personScreamingField; @property (nonatomic, retain) UIImageView *personScreamingImage; @property (nonatomic, retain) NSMutableArray *funnyButtonSayings; @property (nonatomic, retain) UILabel *funnyButtonSayingsLabel; //Mailing the scream related @property (nonatomic, retain) IBOutlet UILabel *mailStatusMessage; @property (nonatomic, retain) IBOutlet UIButton *shareButton; //Scream Button - (IBAction) scream: (id) sender; //Mail the scream - (IBAction) showPicker: (id)sender; - (void)displayComposerSheet; - (void)launchMailAppOnDevice; @end Here's the top of .m: #import "ScreamViewController.h" //top of code has Audio session callback function for responding to audio route changes (from Apple's code), then my code continues... @implementation ScreamViewController @synthesize appSoundPlayer; // AVAudioPlayer object for playing the selected scream @synthesize soundFileURL; // Path to the scream @synthesize interruptedOnPlayback; // Was application interrupted during audio playback @synthesize playing; // Track playing/not playing state @synthesize screamButton; //Press this button, girls scream. @synthesize screams; //Mutable array holding strings pointing to sound files of screams. @synthesize personScreaming; //Mutable array tracking the person doing the screaming @synthesize photoArray; //Mutable array holding strings pointing to photos of screaming girls @synthesize personScreamingField; //Field updates to announce which girl is screaming. @synthesize personScreamingImage; //Updates to show image of the screamer. @synthesize funnyButtonSayings; //Mutable array holding the sayings @synthesize funnyButtonSayingsLabel; //Label that updates with the funnyButtonSayings @synthesize mailStatusMessage; //did the email go out @synthesize shareButton; //share scream via email Next line begins the block with the offending code: - (IBAction) scream: (id) sender { //Play a click sound effect SystemSoundID soundID; NSString *sfxPath = [[NSBundle mainBundle] pathForResource:@"aClick" ofType:@"caf"]; AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:sfxPath],&soundID); AudioServicesPlaySystemSound (soundID); // Because someone may slam the scream button over and over, //must stop current sound, then begin next if ([self appSoundPlayer] != nil) { [[self appSoundPlayer] setDelegate:nil]; [[self appSoundPlayer] stop]; [self setAppSoundPlayer: nil]; } //after selecting a random index in the array (did that in View Did Load), //we move to the next scream on each click. //First check... //Are we past the end of the array? if (currentScreamIndex == [screams count]) { currentScreamIndex = 0; } //Get the string at the index in the personScreaming array currentScream = [screams objectAtIndex: currentScreamIndex]; //Get the string at the index in the personScreaming array NSString *screamer = [personScreaming objectAtIndex:currentScreamIndex]; //Log the string to the console NSLog (@"playing scream: %@", screamer); // Display the string in the personScreamingField field NSString *listScreamer = [NSString stringWithFormat:@"scream by: %@", screamer]; [personScreamingField setText:listScreamer]; // Gets the file system path to the scream to play. NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: currentScream ofType: @"caf"]; // Converts the sound's file path to an NSURL object NSURL *newURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; self.soundFileURL = newURL; [newURL release]; [[AVAudioSession sharedInstance] setDelegate: self]; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil]; // Registers the audio route change listener callback function AudioSessionAddPropertyListener ( kAudioSessionProperty_AudioRouteChange, audioRouteChangeListenerCallback, self ); // Activates the audio session. NSError *activationError = nil; [[AVAudioSession sharedInstance] setActive: YES error: &activationError]; // Instantiates the AVAudioPlayer object, initializing it with the sound AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: soundFileURL error: nil]; //Error check and continue if (newPlayer != nil) { self.appSoundPlayer = newPlayer; [newPlayer release]; [appSoundPlayer prepareToPlay]; [appSoundPlayer setVolume: 1.0]; [appSoundPlayer setDelegate:self]; //NEXT LINE IS FLAGGED BY INSTRUMENTS AS LEAKY [appSoundPlayer play]; playing = YES; //Get the string at the index in the photoArray array NSString *screamerPic = [photoArray objectAtIndex:currentScreamIndex]; //Log the string to the console NSLog (@"displaying photo: %@", screamerPic); // Display the image of the person screaming personScreamingImage.image = [UIImage imageNamed:screamerPic]; //show the share button shareButton.hidden = NO; mailStatusMessage.hidden = NO; mailStatusMessage.text = @"share!"; //Get the string at the index in the funnySayings array currentSayingsIndex = random() % [funnyButtonSayings count]; currentButtonSaying = [funnyButtonSayings objectAtIndex: currentSayingsIndex]; NSString *theSaying = [funnyButtonSayings objectAtIndex:currentSayingsIndex]; [funnyButtonSayingsLabel setText: theSaying]; currentScreamIndex++; } } Here's my dealloc: - (void)dealloc { [appSoundPlayer stop]; [appSoundPlayer release], appSoundPlayer = nil; [screamButton release], screamButton = nil; [mailStatusMessage release], mailStatusMessage = nil; [personScreamingField release], personScreamingField = nil; [personScreamingImage release], personScreamingImage = nil; [funnyButtonSayings release], funnyButtonSayings = nil; [funnyButtonSayingsLabel release], funnyButtonSayingsLabel = nil; [screams release], screams = nil; [personScreaming release], personScreaming = nil; [soundFileURL release]; [super dealloc]; } @end Thanks so much for reading this far! Any input appreciated.

    Read the article

  • Problem with Rotating a UIScrollview

    - by leachianus.gecko
    Hey guys, I am having issues trying to get the pageControl sample code to work with rotation. I managed to get it to rotate but it does not visually loads correctly until I start to scroll (then it works fine). Any Idea on how I can fix this problem? Here is a link to the project if you want to see it in action. This code is based off the PageControl example apple has provided. here is the code: #import "ScrollingViewController.h" #import "MyViewController.h" @interface ScrollingViewController (PrivateMethods) - (void)loadScrollViewWithPage:(int)page; @end @implementation ScrollingViewController @synthesize scrollView; @synthesize viewControllers; - (void)viewDidLoad { amount = 5; [super viewDidLoad]; [self setupPage]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidUnload { [scrollView release]; } - (void)dealloc { [super dealloc]; } - (void)setupPage { NSMutableArray *controllers = [[NSMutableArray alloc] init]; for (unsigned i = 0; i < amount; i++) { [controllers addObject:[NSNull null]]; } self.viewControllers = controllers; [controllers release]; // a page is the width of the scroll view scrollView.pagingEnabled = YES; scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * amount, 200); scrollView.showsHorizontalScrollIndicator = NO; scrollView.showsVerticalScrollIndicator = NO; scrollView.scrollsToTop = NO; scrollView.delegate = self; [self loadScrollViewWithPage:0]; [self loadScrollViewWithPage:1]; } #pragma mark - #pragma mark UIScrollViewDelegate stuff - (void)scrollViewDidScroll:(UIScrollView *)_scrollView { if (pageControlIsChangingPage) { return; } /* * We switch page at 50% across */ CGFloat pageWidth = _scrollView.frame.size.width; int dog = floor((_scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1; // pageControl.currentPage = page; [self loadScrollViewWithPage:dog - 1]; [self loadScrollViewWithPage:dog]; [self loadScrollViewWithPage:dog + 1]; } - (void)loadScrollViewWithPage:(int)page { if (page < 0) return; if (page >= amount) return; MyViewController *controller = [viewControllers objectAtIndex:page]; if ((NSNull *)controller == [NSNull null]) { controller = [[MyViewController alloc] initWithPageNumber:page]; [viewControllers replaceObjectAtIndex:page withObject:controller]; [controller release]; } if (nil == controller.view.superview) { CGRect frame = scrollView.frame; frame.origin.x = frame.size.width * page; frame.origin.y = 0; controller.view.frame = frame; [scrollView addSubview:controller.view]; } } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [self setupPage]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return YES; } #pragma mark - #pragma mark PageControl stuff @end

    Read the article

  • AVAudioRecorder Memory Leak

    - by Eric Ranschau
    I'm hoping someone out there can back me up on this... I've been working on an application that allows the end user to record a small audio file for later playback and am in the process of testing for memory leaks. I continue to very consistently run into a memory leak when the AVAudioRecorder's "stop" method attempts to close the audio file to which it's been recording. This really seems to be a leak in the framework itself, but if I'm being a bonehead you can tell me. To illustrate, I've worked up a stripped down test app that does nothing but start/stop a recording w/ the press of a button. For the sake of simplicty, everything happens in app. delegate as follows: @synthesize audioRecorder, button; @synthesize window; - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // create compplete path to database NSString *tempPath = NSTemporaryDirectory(); NSString *audioFilePath = [tempPath stringByAppendingString:@"/customStatement.caf"]; // define audio file url NSURL *audioFileURL = [[NSURL alloc] initFileURLWithPath:audioFilePath]; // define audio recorder settings NSDictionary *settings = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kAudioFormatAppleIMA4], AVFormatIDKey, [NSNumber numberWithInt:1], AVNumberOfChannelsKey, [NSNumber numberWithInt:AVAudioQualityLow], AVSampleRateConverterAudioQualityKey, [NSNumber numberWithFloat:44100], AVSampleRateKey, [NSNumber numberWithInt:8], AVLinearPCMBitDepthKey, nil ]; // define audio recorder audioRecorder = [[AVAudioRecorder alloc] initWithURL:audioFileURL settings:settings error:nil]; [audioRecorder setDelegate:self]; [audioRecorder setMeteringEnabled:YES]; [audioRecorder prepareToRecord]; // define record button button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(handleTouch_recordButton) forControlEvents:UIControlEventTouchUpInside]; [button setFrame:CGRectMake(110.0, 217.5, 100.0, 45.0)]; [button setTitle:@"Record" forState:UIControlStateNormal]; [button setTitle:@"Stop" forState:UIControlStateSelected]; // configure the main view controller UIViewController *viewController = [[UIViewController alloc] init]; [viewController.view addSubview:button]; // add controllers to window [window addSubview:viewController.view]; [window makeKeyAndVisible]; // release [audioFileURL release]; [settings release]; [viewController release]; return YES; } - (void) handleTouch_recordButton { if ( ![button isSelected] ) { [button setSelected:YES]; [audioRecorder record]; } else { [button setSelected:NO]; [audioRecorder stop]; } } - (void) dealloc { [audioRecorder release]; [button release]; [window release]; [super dealloc]; } The stack trace from Instruments that shows pretty clearly that the "closeFile" method in the AVFoundation code is leaking...something. You can see a screen shot of the Instruments session here: Developer Forums: AVAudioRecorder Memory Leak Any thoughts would be greatly appreciated!

    Read the article

  • TTLauncherItem: change badge immediately (or: how to refresh TTLauncherView)

    - by vikingosegundo
    I have a TTLauncherView with some TTLauncherItems. These show badges, representing messages from the network. I set the badges in viewWillAppear:, so if I switch to another view and then return, the correct badges are shown. But I want to update the badges as soon a message comes in. Calling setNeedsDisplay on TTLauncherView doesn't help? How can I refresh the TTLauncherView? in my MessageReceiver class I do this: TTNavigator* navigator = [TTNavigator navigator]; [(OverviewController *)[navigator viewControllerForURL:@"tt://launcher"] reloadLauncherView] ; My TTViewController-derived OverviewController @implementation OverviewController - (id)init { if (self = [super init]) { self.title = OverviewTitle; } return self; } - (void)dealloc { [items release]; [overView release]; [super dealloc]; } -(void)viewDidLoad { [super viewDidLoad]; overView = [[TTLauncherView alloc] initWithFrame:self.view.bounds]; overView.backgroundColor = [UIColor whiteColor]; overView.delegate = self; overView.columnCount = 4; items = [[NSMutableArray alloc] init]; for(int i = 1; i <= NumberOfBars; ++i){ NSString *barID = [NSString stringWithFormat:NameFormat, IDPrefix, i]; TTLauncherItem *item = [[[TTLauncherItem alloc] initWithTitle:barID image:LogoPath URL:[NSString stringWithFormat:@"tt://item/%d", i] canDelete:NO] autorelease]; [barItems addObject: item]; } overView.pages = [NSArray arrayWithObject:items]; [self.view addSubview:overView]; } -(void)viewWillAppear:(BOOL)animated { for(int i = 0; i <[barItems count]; i++){ TTLauncherItem *item = [items objectAtIndex:i]; NSString *barID = [NSString stringWithFormat:NameFormat, IDPrefix, i+1]; P1LOrderDispatcher *dispatcher = [OrderDispatcher sharedInstance]; P1LBarInbox *barInbox = [dispatcher.barInboxMap objectForKey:barID]; item.badgeNumber = [[barInbox ordersWithState:OrderState_New]count]; } [super viewWillAppear:animated]; } - (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item { TTDPRINT(@"%@", item); TTNavigator *navigator = [TTNavigator navigator]; [navigator openURLAction:[TTURLAction actionWithURLPath:item.URL]]; } -(void)reloadLauncherView { [overView setNeedsDisplay];//This doesn't work } @end

    Read the article

  • UITabBarController rotation problem with popViewControllerAnimated and selectedIndex (iPhone SDK)

    - by rjobidon
    Hi! This is a very important auto rotate issue and easy to reproduce. My application has a UITabBarController. Each tab is a UINavigationController. Auto rotation is handled with normal calls to shouldAutorotateToInterfaceOrientation and didRotateFromInterfaceOrientation. The interface rotates normally until I call UIViewController.popViewControllerAnimated and change UITabBarController.selectedIndex. Steps to reproduce: Create a demo Tab Bar Application. Add the following code to the App Delegate .h file: #import <UIKit/UIKit.h> @interface TestRotationAppDelegate : NSObject { UIWindow *window; UITabBarController *tabBarController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UITabBarController *tabBarController; -(void)doAction; @end // Redefine the interface to cach rotation messages @interface UITabBarController (TestRotation1AppDelegate) @end Add the following code to the App Delegate .m file: #import "TestRotationAppDelegate.h" @implementation TestRotationAppDelegate @synthesize window; @synthesize tabBarController; -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [window addSubview:tabBarController.view]; [window makeKeyAndVisible]; return YES; } -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } -(void)dealloc { [tabBarController release]; [window release]; [super dealloc]; } @end @implementation UITabBarController (TestRotation1AppDelegate) -(void)viewDidLoad { [super viewDidLoad]; // Add a third tab and push a view UIViewController *view1 = [[UIViewController alloc] init]; view1.title = @"Third"; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:view1]; NSMutableArray *array = [[NSMutableArray alloc] init]; [array addObjectsFromArray:self.viewControllers]; [array addObject:nav]; self.viewControllers = array; // Push view2 inside the third tab UIViewController *view2 = [[UIViewController alloc] init]; [nav pushViewController:view2 animated:YES]; // Create a button to pop view2 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(50, 50, 220, 38); [button setTitle:@"Pop this view" forState:UIControlStateNormal]; [button addTarget:self action:@selector(doAction) forControlEvents:UIControlEventTouchUpInside]; [view2.view addSubview:button]; } -(void) doAction { // ROTATION PROBLEM BEGINS HERE // Remove one line of code and the problem doesn't occur. [self.selectedViewController popViewControllerAnimated:YES]; self.selectedIndex = 0; } -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } @end The interface auto rotates normally until you tap the button on tab #3. Your help will be geatly appreciated!

    Read the article

  • NSObjectController confusion binding to a class property. Help!

    - by scottw
    Hi, I'm teaching myself cocoa and enjoying the experience most of the time. I have been struggling all day with a simple problem that google has let me down on. I have read the Cocoa Bindings Program Topics and think I grok it but still can't solve my issue. I have a very simple class called MTSong that has various properties. I have used @synthesize to create getter/setters and can use KVC to change properties. i.e in my app controller the following works: mySong = [[MTSong alloc]init]; [mySong setValue:@"2" forKey:@"version"]; In case I am doing something noddy in my class code MTSong.h is: #import <Foundation/Foundation.h> @interface MTSong : NSObject { NSNumber *version; NSString *name; } @property(readwrite, assign) NSNumber *version; @property(readwrite, assign) NSString *name; @end and MTSong.m is: #import "MTSong.h" @implementation MTSong - (id)init { [super init]; return self; } - (void)dealloc { [super dealloc]; } @synthesize version; @synthesize name; @end In Interface Builder I have a label (NSTextField) that I want to update whenever I use KVC to change the version of the song. I do the following: Drag NSObjectController object into the doc window and in the Inspector-Attributes I set: Mode: Class Class Name: MTSong Add a key called version and another called name Go to Inspector-Bindings-Controller Content Bind To: File's Owner (Not sure this is right...) Model Key Path: version Select the cell of the label and go to Inspector Bind to: Object Controller Controller Key: mySong Model Key Path: version I have attempted changing the Model Key Path in step 2 to "mySong" which makes more sense but the compiler complains. Any suggestions would be greatly appreciated. Scott Update Post Comments I wasn't exposing mySong property so have changed my AppController.h to be: #import <Cocoa/Cocoa.h> @class MTSong; @interface AppController : NSObject { IBOutlet NSButton *start; IBOutlet NSTextField *tf; MTSong *mySong; } -(IBAction)convertFile:(id)sender; @end I suspect File's owner was wrong as I am not using a document based application and I need to bind to the AppController, so step 2 is now: Go to Inspector-Bindings-Controller Content Bind To: App Controller Model Key Path: mySong I needed to change 3. to Select the cell of the label and go to Inspector Bind to: Object Controller Controller Key: selection Model Key Path: version All compiles and is playing nice!

    Read the article

  • Is this a good way to do a game loop for an iPhone game?

    - by Danny Tuppeny
    Hi all, I'm new to iPhone dev, but trying to build a 2D game. I was following a book, but the game loop it created basically said: function gameLoop update() render() sleep(1/30th second) gameLoop The reasoning was that this would run at 30fps. However, this seemed a little mental, because if my frame took 1/30th second, then it would run at 15fps (since it'll spend as much time sleeping as updating). So, I did some digging and found the CADisplayLink class which would sync calls to my gameLoop function to the refresh rate (or a fraction of it). I can't find many samples of it, so I'm posting here for a code review :-) It seems to work as expected, and it includes passing the elapsed (frame) time into the Update method so my logic can be framerate-independant (however I can't actually find in the docs what CADisplayLink would do if my frame took more than its allowed time to run - I'm hoping it just does its best to catch up, and doesn't crash!). // // GameAppDelegate.m // // Created by Danny Tuppeny on 10/03/2010. // Copyright Danny Tuppeny 2010. All rights reserved. // #import "GameAppDelegate.h" #import "GameViewController.h" #import "GameStates/gsSplash.h" @implementation GameAppDelegate @synthesize window; @synthesize viewController; - (void) applicationDidFinishLaunching:(UIApplication *)application { // Create an instance of the first GameState (Splash Screen) [self doStateChange:[gsSplash class]]; // Set up the game loop displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(gameLoop)]; [displayLink setFrameInterval:2]; [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; } - (void) gameLoop { // Calculate how long has passed since the previous frame CFTimeInterval currentFrameTime = [displayLink timestamp]; CFTimeInterval elapsed = 0; // For the first frame, we want to pass 0 (since we haven't elapsed any time), so only // calculate this in the case where we're not the first frame if (lastFrameTime != 0) { elapsed = currentFrameTime - lastFrameTime; } // Keep track of this frames time (so we can calculate this next time) lastFrameTime = currentFrameTime; NSLog([NSString stringWithFormat:@"%f", elapsed]); // Call update, passing the elapsed time in [((GameState*)viewController.view) Update:elapsed]; } - (void) doStateChange:(Class)state { // Remove the previous GameState if (viewController.view != nil) { [viewController.view removeFromSuperview]; [viewController.view release]; } // Create the new GameState viewController.view = [[state alloc] initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT) andManager:self]; // Now set as visible [window addSubview:viewController.view]; [window makeKeyAndVisible]; } - (void) dealloc { [viewController release]; [window release]; [super dealloc]; } @end Any feedback would be appreciated :-) PS. Bonus points if you can tell me why all the books use "viewController.view" but for everything else seem to use "[object name]" format. Why not [viewController view]?

    Read the article

  • UITableView not getting populated

    - by jayshree430
    Hi. I have a peculiar problem. I created a normal Objective c class called SampleTable. I then extended UITableView instead of NSObject. Then in the initWithFrame constructor i initialized the table. I also made a NSMutableArray object for the datasource. I also conformed UITableViewDelegate and UITableViewDatasource. I have overridden the necessary methods also. Now i made an object of this class in another class, and added the object as a subview. The tableView is getting drawn according to the CGRectMake() coordinates i gave to the initWithFrame constructor. But it is not getting populated with the data. I dnt know what the problem is . Can plz someone help me. SampleTable.h #import @interface SampleTable : UITableView { NSMutableArray *ItemArray; } @property (nonatomic,retain) NSMutableArray *ItemArray; -(NSMutableArray *) displayItemArray; @end SampleTable.m #import "SampleTable.h" @implementation SampleTable @synthesize ItemArray; -(id)initWithFrame:(CGRect)frm { [super initWithFrame:frm]; self.delegate=self; self.dataSource=self; [self reloadData]; return self; } -(NSMutableArray *) displayItemArray { if(ItemArray==nil) { ItemArray=[[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",nil]; } return ItemArray; } (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [ItemArray count]; } (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell==nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; [cell autorelease]; } NSString *temp=[self.ItemArray objectAtIndex:indexPath.row]; cell.textLabel.text = temp; return cell; } (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"didselect"); } -(void) dealloc { [ItemArray release]; [super dealloc]; } @end

    Read the article

  • copied the reachability-test from apple, but the linker gives a failure

    - by nico
    i have tried to use the reachability-project published by apple to detect a reachability in an own example. i copied the most initialization, but i get this failure in the linker: Ld build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test normal armv6 cd /Users/uid04100/Documents/TEST setenv IPHONEOS_DEPLOYMENT_TARGET 3.1.3 setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -L/Users/uid04100/Documents/TEST/build/Debug-iphoneos -F/Users/uid04100/Documents/TEST/build/Debug-iphoneos -filelist /Users/uid04100/Documents/TEST/build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test.LinkFileList -dead_strip -miphoneos-version-min=3.1.3 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/uid04100/Documents/TEST/build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test Undefined symbols: "_SCNetworkReachabilitySetCallback", referenced from: -[Reachability startNotifer] in Reachability.o "_SCNetworkReachabilityCreateWithAddress", referenced from: +[Reachability reachabilityWithAddress:] in Reachability.o "_SCNetworkReachabilityScheduleWithRunLoop", referenced from: -[Reachability startNotifer] in Reachability.o "_SCNetworkReachabilityGetFlags", referenced from: -[Reachability connectionRequired] in Reachability.o -[Reachability currentReachabilityStatus] in Reachability.o "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from: -[Reachability stopNotifer] in Reachability.o "_SCNetworkReachabilityCreateWithName", referenced from: +[Reachability reachabilityWithHostName:] in Reachability.o ld: symbol(s) not found collect2: ld returned 1 exit status my delegate.h: import @class Reachability; @interface testAppDelegate : NSObject { UIWindow *window; UINavigationController *navigationController; Reachability* hostReach; Reachability* internetReach; Reachability* wifiReach; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; @end my delegate.m: import "testAppDelegate.h" import "SecondViewController.h" import "Reachability.h" @implementation testAppDelegate @synthesize window; @synthesize navigationController; (void) updateInterfaceWithReachability: (Reachability*) curReach { if(curReach == hostReach) { BOOL connectionRequired= [curReach connectionRequired]; if(connectionRequired) { //in these brackets schould be some code with sense, if i´m getting it to run } else { } } if(curReach == internetReach) { } if(curReach == wifiReach) { } } //Called by Reachability whenever status changes. - (void) reachabilityChanged: (NSNotification* )note { Reachability* curReach = [note object]; NSParameterAssert([curReach isKindOfClass: [Reachability class]]); [self updateInterfaceWithReachability: curReach]; } (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after application launch // Observe the kNetworkReachabilityChangedNotification. When that notification is posted, the // method "reachabilityChanged" will be called. // [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil]; //Change the host name here to change the server your monitoring hostReach = [[Reachability reachabilityWithHostName: @"www.apple.com"] retain]; [hostReach startNotifer]; [self updateInterfaceWithReachability: hostReach]; internetReach = [[Reachability reachabilityForInternetConnection] retain]; [internetReach startNotifer]; [self updateInterfaceWithReachability: internetReach]; wifiReach = [[Reachability reachabilityForLocalWiFi] retain]; [wifiReach startNotifer]; [self updateInterfaceWithReachability:wifiReach]; [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; } (void)dealloc { [navigationController release]; [window release]; [super dealloc]; } @end

    Read the article

  • [obj-c] autorelease problem

    - by BQuadra
    Why the NSArray allocated with arrayWithObjects dealloc automatically if already used by BObject object?? in teory NSArray must remain allocated all the BObject life time... [[BObject alloc] initObjectName:@"oneObject" states: [NSArray arrayWithObjects: [[State alloc] initStateName:@"stand_front" singleImg:[NSArray arrayWithObjects:[UIImage imageNamed:@"front_1.png"], nil]], [[State alloc] initStateName:@"front_walking" frames: [NSArray arrayWithObjects: [UIImage imageNamed:@"front_1.png"], [UIImage imageNamed:@"front_2.png"], [UIImage imageNamed:@"front_3.png"], [UIImage imageNamed:@"front_4.png"], [UIImage imageNamed:@"front_5.png"], [UIImage imageNamed:@"front_6.png"], [UIImage imageNamed:@"front_7.png"], [UIImage imageNamed:@"front_8.png"], nil] duration:0.8 repeat:0], nil] isSolid:TRUE];

    Read the article

  • TabBarController rotation problem with popViewControllerAnimated and selectedIndex

    - by rjobidon
    Hi! This is a very important auto rotate issue and easy to reproduce. My application has a UITabBarController. Each tab is a UINavigationController. Auto rotation is handled with normal calls to shouldAutorotateToInterfaceOrientation and didRotateFromInterfaceOrientation. The interface rotates normally until I call UIViewController.popViewControllerAnimated and change UITabBarController.selectedIndex. Steps to reproduce: Create a demo Tab Bar Application. Add the following code to the App Delegate .h file: #import <UIKit/UIKit.h> @interface TestRotation2AppDelegate : NSObject { UIWindow *window; UITabBarController *tabBarController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UITabBarController *tabBarController; (void)doAction; @end // Redefine the interface to cach rotation messages @interface UITabBarController (TestRotation1AppDelegate) @end Add the following code to the App Delegate .m file: #import "TestRotation2AppDelegate.h" @implementation TestRotation2AppDelegate @synthesize window; @synthesize tabBarController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [window addSubview:tabBarController.view]; [window makeKeyAndVisible]; return YES; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (void)dealloc { [tabBarController release]; [window release]; [super dealloc]; } @end @implementation UITabBarController (TestRotation1AppDelegate) - (void)viewDidLoad { [super viewDidLoad]; // Add a third tab and push a view UIViewController *view1 = [[UIViewController alloc] init]; view1.title = @"Third"; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:view1]; NSMutableArray *array = [[NSMutableArray alloc] init]; [array addObjectsFromArray:self.viewControllers]; [array addObject:nav]; self.viewControllers = array; // Push view2 inside the third tab UIViewController *view2 = [[UIViewController alloc] init]; [nav pushViewController:view2 animated:YES]; // Create a button to pop view2 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(50, 50, 220, 38); [button setTitle:@"Pop this view" forState:UIControlStateNormal]; [button addTarget:self action:@selector(doAction) forControlEvents:UIControlEventTouchUpInside]; [view2.view addSubview:button]; } - (void) doAction { // ROTATION PROBLEM BEGINS HERE // Remove one line of code and the problem doesn't occur. [self.selectedViewController popViewControllerAnimated:YES]; self.selectedIndex = 0; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } @end The interface auto rotates normally until you tap the button on tab #3. Your help will be geatly appreciated!

    Read the article

  • Undefined symbols for architecture armv7 using route-me

    - by Alex
    I'm trying to compile my project including route-me using armv7 although am struggling with the following error, i have older versions of the same project in git which compiles fine with armv7 so a setting must have changed somewhere to break it, here is the error: Undefined symbols for architecture armv7: "_pj_fwd", referenced from: -[RMProjection latLongToPoint:] in libMapView.a(RMProjection.o) "_pj_inv", referenced from: -[RMProjection pointToLatLong:] in libMapView.a(RMProjection.o) "_pj_init_plus", referenced from: -[RMProjection initWithString:InBounds:] in libMapView.a(RMProjection.o) "_pj_free", referenced from: -[RMProjection dealloc] in libMapView.a(RMProjection.o) ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation) Any help would be greatly appreciated.

    Read the article

  • CGContextFillEllipseInRect: invalid context

    - by hakewake
    Hi all, when I launch my app, I keep getting this CGContextFillEllipseInRect: invalid context error. My app is simply to make the circle 'pinchable'. The debugger shows me this: [Session started at 2010-05-23 18:21:25 +0800.] 2010-05-23 18:21:27.140 Erase[8045:207] I'm being redrawn. Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context 2010-05-23 18:21:27.144 Erase[8045:207] New value of counter is 1 2010-05-23 18:21:27.144 Erase[8045:207] I'm being redrawn. Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context 2010-05-23 18:21:27.144 Erase[8045:207] New value of counter is 2 2010-05-23 18:21:27.144 Erase[8045:207] I'm being redrawn. Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context 2010-05-23 18:21:27.144 Erase[8045:207] New value of counter is 3 2010-05-23 18:21:27.145 Erase[8045:207] I'm being redrawn. Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context 2010-05-23 18:21:27.145 Erase[8045:207] New value of counter is 4 2010-05-23 18:21:27.148 Erase[8045:207] I'm being redrawn. Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context 2010-05-23 18:21:27.149 Erase[8045:207] New value of counter is 5 2010-05-23 18:21:27.150 Erase[8045:207] I'm being redrawn. Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context 2010-05-23 18:21:27.150 Erase[8045:207] New value of counter is 6 My implementation file is: // // ImageView.m // Erase // #import "ImageView.h" #import "EraseViewController.h" @implementation ImageView -(void)setNewRect:(CGRect)anotherRect{ newRect = anotherRect; } - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { newRect = CGRectMake(0,0,0,0); ref = UIGraphicsGetCurrentContext(); } return self; } - (void)drawRect:(CGRect)rect { static int counter = 0; CGRect veryNewRect = CGRectMake(30.0, 210.0, 60.0, 60.0); NSLog(@"I'm being redrawn."); if (counter == 0){ CGContextFillEllipseInRect(ref, veryNewRect); } else{ CGContextFillEllipseInRect(ref, rect); } counter++; NSLog(@"New value of counter is %d", counter); } - (void)setNeedsDisplay{ [super setNeedsDisplay]; [self drawRect:newRect]; } - (void)dealloc { [super dealloc]; } @end I've got two questions: 1) Why is it updating counter 6 times? I removed the line [super setNeedsDisplay]; but it becomes 4 times. 2) What is that invalid context error? Thanks guys.

    Read the article

  • Iphone App crashing on launch

    - by Declan Scott
    Hey, My simple iphone app is crashing on launch, it says "the application downloadText quit unexcpectedly i none of these windows that pop up when a mac app crashes and has a send to Apple button. My .h is below and i would greatly appreciate it if anyone could give me a hand as to what's wrong? thanks, Declan `#import "downloadTextViewController.h" @implementation downloadTextViewController // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { NSString *myPath = [self saveFilePath]; NSLog(myPath); BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:myPath]; if (fileExists) { NSArray *values = [[NSArray alloc] initWithContentsOfFile:myPath]; textView.text = [values objectAtIndex:0]; [values release]; } // notification UIApplication *myApp = [UIApplication sharedApplication]; // add yourself to the dispatch table [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:myApp]; [super viewDidLoad]; } (IBAction)fetchData { /// Show activityIndicator / progressView NSURLRequest *downloadRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://simpsonatyapps.com/exampletext.txt"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:1.0]; NSURLConnection *downloadConnection = [[NSURLConnection alloc] initWithRequest:downloadRequest delegate:self]; if (downloadConnection) downloadedData = [[NSMutableData data] retain]; else { /// Error message } } (void)connection:(NSURLConnection *)downloadConnection didReceiveData:(NSData *)data { [downloadedData appendData:data]; NSString *file = [[NSString alloc] initWithData:downloadedData encoding:NSUTF8StringEncoding]; textView.text = file; /// Remove activityIndicator / progressView [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1]; } (NSString *) saveFilePath { NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); return [[pathArray objectAtIndex:0] stringByAppendingPathComponent:@"savedddata.plist"]; } (void)applicationWillTerminate:(UIApplication *)application { NSArray *values = [[NSArray alloc] initWithObjects:textView.text,nil]; [values writeToFile:[self saveFilePath] atomically:YES]; [values release]; } (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } (void)dealloc { [super dealloc]; } (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse { return nil; } @end `

    Read the article

  • Activity Indicator not displaying based on whether the UIWebView is loading or not...

    - by Jack W-H
    Hi folks Sorry if this is an easy one. Basically, here is my code: MainViewController.h: // // MainViewController.h // Site // // Created by Jack Webb-Heller on 19/03/2010. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import "FlipsideViewController.h" @interface MainViewController : UIViewController <UIWebViewDelegate, FlipsideViewControllerDelegate> { IBOutlet UIWebView *webView; IBOutlet UIActivityIndicatorView *spinner; } - (IBAction)showInfo; @property(nonatomic,retain) UIWebView *webView; @property(nonatomic,retain) UIActivityIndicatorView *spinner; @end MainViewController.m: // // MainViewController.m // Site // // Created by Jack Webb-Heller on 19/03/2010. // Copyright __MyCompanyName__ 2010. All rights reserved. // #import "MainViewController.h" #import "MainView.h" @implementation MainViewController @synthesize webView; @synthesize spinner; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization } return self; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { NSURL *siteURL; NSString *siteURLString; siteURLString=[[NSString alloc] initWithString:@"http://www.site.com"]; siteURL=[[NSURL alloc] initWithString:siteURLString]; [webView loadRequest:[NSURLRequest requestWithURL:siteURL]]; [siteURL release]; [siteURLString release]; [super viewDidLoad]; } - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller { [self dismissModalViewControllerAnimated:YES]; } - (void)webViewDidFinishLoad:(UIWebView *)webView { [spinner stopAnimating]; spinner.hidden=FALSE; NSLog(@"viewDidFinishLoad went through nicely"); } - (void)webViewDidStartLoad:(UIWebView *)webView { [spinner startAnimating]; spinner.hidden=FALSE; NSLog(@"viewDidStartLoad seems to be working"); } - (IBAction)showInfo { FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil]; controller.delegate = self; controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:controller animated:YES]; [controller release]; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [spinner release]; [webView release]; [super dealloc]; } @end Unfortunately nothing is ever written to my log, and for some reason the Activity Indicator never seems to appear. What's going wrong here? Thanks folks Jack

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >