Search Results

Search found 61 results on 3 pages for 'fuzzygoat'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • Block declared variable visible outside?

    - by fuzzygoat
    If I declare a variable within a block (see below) is there a way to specify that its visible outside the block if need be? if(turbine_RPM > 0) { int intResult = [sensorNumber:1]; NSNumber *result = [NSNumber numberWithInt:intResult]; } return result; or is the way just to declare outside the block scope? NSNumber *result; if(turbine_RPM > 0) { int intResult = [sensorNumber:1]; result = [NSNumber numberWithInt:intResult]; } return result; many thanks gary

    Read the article

  • Xcode SDK version for testing & release?

    - by fuzzygoat
    I am just putting the finishing touches to an iPhone app that I have written, signed up to the developer program and installed Xcode 3.2.2 (1650) My question is which version of the SDK should I be using to build my application? I was thinking I should be using the latest 3.2 but when I select that I can only access the iPad simulator ... Should I be using 3.1.3 which runs the iPhone simulator. (NB: I originally developed the app in 3.1.2 cheers gary

    Read the article

  • How to load object after saving with encodeWithCoder?

    - by fuzzygoat
    EDIT_002: Further rewrite: if I save using the method below how would the method to load it back in look? (moons is an NSMutableArray of NSNumbers) // ------------------------------------------------------------------- ** // METHOD_002 // ------------------------------------------------------------------- ** -(void)saveMoons:(NSString *)savePath { NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; [moons encodeWithCoder:archiver]; [archiver finishEncoding]; [data writeToFile:savePath atomically:YES]; [archiver release]; [data release]; } EDIT_003: Found it, my problem was that I was using ... [moons encodeWithCoder:archiver]; where I should have been using ... [archiver encodeObject:moons]; Hence the loader would look like: -(void)loadMoons_V3:(NSString *)loadPath { NSData *data = [[NSData alloc] initWithContentsOfFile:loadPath]; NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; [self setMoons:[unarchiver decodeObject]]; [unarchiver finishDecoding]; [unarchiver release]; [data release]; } gary

    Read the article

  • Preload *.wav with SystemSoundID?

    - by fuzzygoat
    I am playing a wav file to give a little audio feedback when a button in my UI is pressed. My question is when you first press the button there is a delay (about 1.5secs) whilst the sound file "sound.wav" is loaded and cached. Is there a way to pre-cache this file (maybe in my viewDidLoad)? I guess I could do it by just playing it a viewDidLoad, but would really need to disable the audio so it does not "beeb" each time the app starts. many thanks for and help. gary EDIT: Looks like my question is a duplicate of this post unless anyone has any new info? Maybe a way to turn the play volume down temporarily, unless the audio is cleared each time through the run loop.

    Read the article

  • Loading from archive?

    - by fuzzygoat
    Can anyone point me in the right direction, I have two sets of load/save methods below that I am playing with to save an array of objects out to disk and then load them back in. I am getting a little confused after calling "saveMoons" how I should go about loading that data back in ... any pointers would be great. -(void)saveMoons:(NSString *)savePath { NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; [moons encodeWithCoder:archiver]; [archiver finishEncoding]; [data writeToFile:savePath atomically:YES]; [data release]; [archiver release]; } -(void)loadMoons:(NSString *)loadPath { NSMutableData *data = [[NSMutableData alloc] initWithContentsOfFile:loadPath]; NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; // [self setMoons:[unarchiver ??????]]; } . // ------------------------------------------------------------------- ** // SIMPLER // ------------------------------------------------------------------- ** -(void)saveMoons_SIMPLE:(NSString *)savePath { NSData *data = [NSKeyedArchiver archivedDataWithRootObject:moons]; [data writeToFile:savePath atomically:YES]; } -(void)loadMoons_SIMPLE:(NSString *)loadPath { [self setMoons:[NSKeyedUnarchiver unarchiveObjectWithFile:loadPath]]; } // ------------------------------------------------------------------- ** // // ------------------------------------------------------------------- ** gary

    Read the article

  • Printing Instance ID to NSLog?

    - by fuzzygoat
    In the dealloc method for a class how would I print out the ID (or some other unique identifier) for the instance being deallocated? - (void)dealloc { NSLog(@"_deallocing: ??"); [super dealloc]; } Is this possible? I am just trying to get a little more feedback in the console as an aid to learning. many thanks -gary-

    Read the article

  • Accessing View in awakeFromNib?

    - by fuzzygoat
    I have been trying to set a UIImageView background color (see below) in awakeFromNib [imageView setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1.0]]; When it did not work, I realised that its probably because the view has not loaded yet and I should move the color change to viewDidLoad. Can I just verify that I have this right? gary

    Read the article

  • Releasing instance if service not enabled?

    - by fuzzygoat
    I would just like to check if I have this right, I am creating an instance of CCLocationManager and then checking if location services are enabled. If it is not enabled I then report an error, release the instance and carry on, does that look/sound right? locationManager = [[CLLocationManager alloc] init]; BOOL supportsService = [locationManager locationServicesEnabled]; if(supportsService) { [locationManager setDelegate:self]; [locationManager setDistanceFilter:kCLDistanceFilterNone]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [locationManager startUpdatingLocation]; } else { NSLog(@"Location services not enabled."); [locationManager release]; } ... ... ... more code cheers gary

    Read the article

  • initializer not constant?

    - by fuzzygoat
    Quick question if I may: I am just curious about the following (see below) Xcode says "initializer element is not constant" why this does not work, I guess its the NSArray ... static NSArray *stuffyNames = [NSArray arrayWithObjects:@"Ted",@"Dog",@"Snosa",nil]; and this does ... static NSString *stuffyNames[3] = {@"Ted",@"Dog",@"Snosa"}; gary

    Read the article

  • @synthesize with UITabBarController?

    - by fuzzygoat
    I am curious if there is a good reason I should / should not be using @synthesize for the tabBarController below, or does it not matter? @implementation ScramAppDelegate @synthesize window; @synthesize tabBarController; -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self setTabBarController:[[UITabBarController alloc] init]]; [window addSubview:[tabBarController view]]; [window makeKeyAndVisible]; return YES; } -(void)dealloc { [tabBarController release]; [self setTabBarController: nil]; [window release]; [super dealloc]; } OR @implementation ScramAppDelegate @synthesize window; -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { tabBarController = [[UITabBarController alloc] init]; [window addSubview:[tabBarController view]]; [window makeKeyAndVisible]; return YES; } -(void)dealloc { [tabBarController release]; [window release]; [super dealloc]; } cheers Gary

    Read the article

  • @property, setter and getter question?

    - by fuzzygoat
    NSString *statusValue; NSString *currentValue; @property(retain, nonatomic) NSString *statusValue; @property(retain, nonatomic) NSString *currentValue; @synthesize statusValue; @sythnesize currentValue; Given the above, if I am setting one variable to another is it work doing ... [self setStatusValue: currentValue]; or should I use the property again and use [self setStatusValue: [self currentValue]]; I suppose the latter (although maybe overkill) does tell the reader that we are using one of the objects instance variables and not some local variable. just curious really ... gary

    Read the article

  • Where to #include?

    - by fuzzygoat
    In my past applications I have been #importing into my *.h files where needed. I have not really thought much about this before as I have not had any problems, but today I spotted something that got me to thinking that maybe I should be #import-ing into my .m files and using @class where needed in the headers (.h) Can anyone shine any light on the way its supposed to be done or best practice? gary

    Read the article

  • iPhone, confusing memory leak.

    - by fuzzygoat
    Can anyone tell me what I am doing wrong with the bottom section of code. I was sure it was fine but "Leaks" says it is leaking which quickly changing it o the top version stops, just not sure as to why the bottom variation fails? // Leaks says this is OK if([elementName isEqualToString:@"rotData-requested"]) { int myInt = [[self elementValue] intValue]; NSNumber *valueAsNumber = [NSNumber numberWithInt:myInt]; [self setRotData:valueAsNumber]; return; } . // Leaks says this LEAKS if([elementName isEqualToString:@"rotData-requested"]) { NSNumber *valueAsNumber = [NSNumber numberWithInt:[[self elementValue] intValue]]; [self setRotData:valueAsNumber]; return; } any help would be appreciated. gary

    Read the article

  • UITableView setting standalone delegate object?

    - by fuzzygoat
    Hi have setup a sample application using a UITableView. Initially I did this by conforming my controller to and , added a tableView in IB and connected "datasource" & "delegate" to Files Owner. It all works so thats good. What I have been trying out is creating my own class for the delegate. I created a new class and added and , but quickly found I could not connect the tableViewdataSource / delegate. To solve this I added an "Object" (NSObject) in IB and set it to my new class. I then connected the dataSource and delegate outlets to this object. It sort of works, the app runs and displays the tableView, but when I try and scroll the table the app crashes. Can I ask if I am going about this the right way? gary

    Read the article

  • Animating a pulsing UILabel?

    - by fuzzygoat
    I am trying to animate the color the the text on a UILabel to pulse from: [Black] to [White] to [Black] and repeat. - (void)timerFlash:(NSTimer *)timer { [[self navTitle] setTextColor:[[UIColor whiteColor] colorWithAlphaComponent:0.0]]; [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{[[self navTitle] setTextColor:[[UIColor whiteColor] colorWithAlphaComponent:1.0]];} completion:nil]; } . [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFlash:) userInfo:nil repeats:YES]]; Firstly I am not sure of my method, my plan (as you can see above) was to set up a animation block and call it using a repeating NSTimer until canceled. My second problem (as you can see above) is that I am animating from black (alpha 0) to white (alpha 1) but I don't know how to animate back to black again so the animation loops seamlessly Essentially what I want is the text color to pulse on a UILabel until the user presses a button to continue. EDIT_001: I was getting into trouble because you can't animate [UILabel setColor:] you can however animated [UILabel setAlpha:] so I am going to give that a go. EDIT_002: - (void)timerFlash:(NSTimer *)timer { [[self navTitle] setAlpha:0.5]; [UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{[[self navTitle] setAlpha:0.9];} completion:nil]; } This works (BTW: I do want it to stop which is why I hooked it up to a NSTimer so I can cancel that) the only thing is that this animates from midGray to nearWhite and then pops back. Does anyone know how I would animate back from nearWhite to midGray so I get a nice smooth cycle? EDIT_003: (Solution) The code suggested by dave DeLong (see below) does indeed work when modified to use the CALayer opacity style attribute: UILabel *navTitle; @property(nonatomic, retain) UILabel *navTitle; . // ADD ANIMATION CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"opacity"]; [anim setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; [anim setFromValue:[NSNumber numberWithFloat:0.5]]; [anim setToValue:[NSNumber numberWithFloat:1.0]]; [anim setAutoreverses:YES]; [anim setDuration:0.5]; [[[self navTitle] layer] addAnimation:anim forKey:@"flash"]; . // REMOVE ANIMATION [[[self navTitle] layer] removeAnimationForKey:@"flash__"];

    Read the article

  • Casting to specify unknown object type?

    - by fuzzygoat
    In the following code I have a view object that is an instance of UIScrollView, if I run the code below I get warnings saying that "UIView might not respond to -setContentSize etc." UIImage *image = [UIImage imageNamed:@"Snowy_UK.jpg"]; imageView = [[UIImageView alloc] initWithImage:image]; [[self view] addSubview:imageView]; [[self view] setContentSize:[image size]]; [[self view] setMaximumZoomScale:2.0]; [[self view] setMinimumZoomScale: [[self view] bounds].size.width / [image size].width]; I have checked the type of the object and [self view] is indeed a UIScrollView. I am guessing that this is just the compiler making a bad guess as to the type and the solution is simply to cast the object to the correct type manually, am I getting this right? UIScrollView *scrollView = (UIScrollView *)[self view]; UIImage *image = [UIImage imageNamed:@"Snowy_UK.jpg"]; imageView = [[UIImageView alloc] initWithImage:image]; [[self view] addSubview:imageView]; [scrollView setContentSize:[image size]]; [scrollView setMaximumZoomScale:2.0]; [scrollView setMinimumZoomScale: [scrollView bounds].size.width / [image size].width]; cheers Gary.

    Read the article

  • With and Without Dot Notation?

    - by fuzzygoat
    I am trying to write the following without using dot notation ... [scrollView setMinimumZoomScale: scrollView.bounds.size.width / image.size.width]; Is this right? [scrollView setMinimumZoomScale: [scrollView bounds].size.width / [image size].width]; cheers Gary.

    Read the article

  • Simple ViewController / View, remove white bar?

    - by fuzzygoat
    I am just looking at setting up a simple viewController programatically, I have a ViewController.xib file that I have set the background color to RED in interface builder. I have also added the following to my AppDelegate.m @implementation syntax_MapViewAppDelegate @synthesize window; -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { viewController = [[MapViewController alloc] init]; [window addSubview:[viewController view]]; [window makeKeyAndVisible]; return YES; } -(void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end When I run the code it does what I expect apart from the white bar at the bottom of the screen, can anyone give me any pointers in how to remove this? I have a feeling I might need to position the view within the window, but I am not sure how? cheers Gary

    Read the article

  • Xcode, Dev Docs Search Field Loosing Focus?

    - by fuzzygoat
    I am having a strange issue with the developer documentation (which i have only noticed after installing Xcode 3.2.3). My problem is that as you type in the search field (upper right) it looses focus and immediately starts looking for the first few letters you type. For example if you looking for "NSObject" you start typing "NSO" and as you type the field looses focus the last 5 characters "bject" just give beeps as you need to reselect the field to type extra characters. Has anyone else come across this or know what the problem might be? cheers Gary.

    Read the article

  • Assigning a selector via SEL type?

    - by fuzzygoat
    I just spotted the following in an online tutorial. It showed 001 as a method for assigning a selector, however I could not get this to work. Am I right in thinking that 001 is not right and 002 is the correct way, or am I doing something wrong with 001? // 001 SEL mySel = [self something]; // 002 SEL mySel = @selector(something); . -(void)something { NSLog(@"YAY"); } Gary

    Read the article

  • Updating Label on previously loaded view?

    - by fuzzygoat
    I am working on a simple app tab-bar based application that has two views. The first is the main application and the second is a simple instruction screen. What I am trying to do is create a update a label on that second screen as things change in the main app. Because the second screen is only simple with one label and some text I am not unloading it once its loaded. After the first viewDidLoad I can update the label just fine, but after that is there a way to catch successive view switches from the tab-bar menu so I can update the label? many thanks gary

    Read the article

  • MVC, can model save/load its data?

    - by fuzzygoat
    Quick question, my data model is a singleton object and it contains a list of names I want archive. My idea is to make the model responsible for loading / saving this data. The ModelLoad will then be called by the ViewControllerviewDidLoad and the ModelSave by ViewControllerapplicationWillTerminate. I could do the load / save directly within the ViewController, but this would be messy as the list of names are on instance variable of the model. gary

    Read the article

  • Using setters On Int?

    - by fuzzygoat
    Just curious, given: unsigned int pulseCounter_001; @property(nonatomic, assign)unsigned int pulseCounter_001; @synthesize pulseCounter_001; Is there any reason to use: [self setPulseCounter_001:0]; Or just use: pulseCounter_001 = 0; Style wise I think the latter says "we are setting an int" better, just curious as to any overheads involved in each? gary

    Read the article

  • UITableView superClass for delegate?

    - by fuzzygoat
    A quick question, I am setting a delegate for UITableView and I have a question regarding setting the delegate and dataSource properties. I have noticed that the properties for delegate and dataSource are not available, I was thinking that adopting the protocols would make them available. But I am now thinking that I maybe have the superclass for my delegate class wrong. Currently I have: -(void)viewDidLoad { TestDelegate *tempDelegate = [[TestDelegate alloc] init]; [self setMyDelegate:tempDelegate]; // setDelegate // setDataSource [tempDelegate release]; [super viewDidLoad]; } My interface for TestDelegate looks like: @interface TestDelegate : NSObject <UITableViewDelegate, UITableViewDataSource> { NSArray *listData; int myCounter; } Can I ask if the above should be: @interface TestDelegate : UITableView <UITableViewDelegate, UITableViewDataSource> { NSArray *listData; int myCounter; } gary EDIT: I think it might be right as NSObject, I have a viewtableView in IB, thats what I will need to connect my delegate class to. I added to tableView in IB so maybe I just need to make it available in Xcode.

    Read the article

< Previous Page | 1 2 3  | Next Page >