Search Results

Search found 290 results on 12 pages for 'nsnumber'.

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

  • Conversion Fahrenheit to celsius programmatically

    - by Doom
    In my project, want to show the weather in fahrenheit first, then if the user wants clickes on conversion, needs to show the weather in celsius. My code is NSNumber *metric = [[NSUserDefaults standardUserDefaults] objectForKey:@"metric"]; NSLog(@"Metric is %@", metric); CGFloat aFloat = [speed floatValue]; CGFloat tFloat = [temperature floatValue]; CGFloat tempFloat = (tFloat-30)/2; NSNumber * p_Number = [NSNumber numberWithFloat:tempFloat]; //Convert mph to kmph if ([metric boolValue]) { [windValueLabel setText:[NSString stringWithFormat:@"%.2f kmph", aFloat * 1.6] ]; temperatureLabel.text = [NSString stringWithFormat:@"%@", p_Number]; } else{ [windValueLabel setText:[NSString stringWithFormat:@"%.2f mph", aFloat / 1.6]]; temperatureLabel.text = [NSString stringWithFormat:@"%@", temperature]; } When u start the app, its working and showing temperature in fahrenheit, but crashes at celsius man... is that the current conversion. help me out guys

    Read the article

  • CAAnimation rotation did not give last stage?

    - by Mikhail Naimy
    hi, i am using following code to rotate the UIView through Swipe gesture .it works fine.but after rotation, it goes to beginning angle or Fromvalue.anyone can help to stop the view in last stage.if i rotate again, it must go from last stage. rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.fromValue = [NSNumber numberWithFloat:0.0 * M_PI]; rotationAnimation.toValue = [NSNumber numberWithFloat:0.5 * M_PI]; //rotationAnimation.toValue = [NSNumber numberWithFloat: 2.5 * 3.15 ]; rotationAnimation.duration = 1.5; //rotationAnimation.cumulative = YES; rotationAnimation.removedOnCompletion = NO; rotationAnimation.repeatCount = 0.0; rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; [self.view.layer addAnimation:rotationAnimation forKey:@"rotationAnimate"];

    Read the article

  • [Doing it Wrong] Auto Boxing of primitives

    - by Jonathan
    I can't seem to figure out how to get Objective-c to auto box my primitives. I assumed that i would be able to do the following NSString* foo = @"12.5"; NSNumber* bar; bar = [foo floatValue]; However i find that i have used to the more verbose method of NSString* foo = @"12.5"; NSNumber* bar; bar = [NSNumber numberWithFloat:[foo floatValue]]; Am i doing it wrong or is this as good as it gets?

    Read the article

  • Objective-c Method to get a number then countdown in 1 every second

    - by Sami
    Hi, i need a little help i have a method which gets value such as 50, it then assigns that value to trackDuration, so NSNumber *trackDuration = 50, i want the method to every second minus 1 from the value of trackDuration and update a label, the label being called duration. Here's what i have so far; - (void) countDown { iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; NSNumber *trackDuration = [NSNumber numberWithDouble:[[iTunes currentTrack] duration]]; while (trackDuration > 0) { trackDuration - 1; int inputSeconds = [trackDuration intValue]; int hours = inputSeconds / 3600; int minutes = ( inputSeconds - hours * 3600 ) / 60; int seconds = inputSeconds - hours * 3600 - minutes * 60; NSString *trackDurationString = [NSString stringWithFormat:@"%.2d:%.2d:%.2d", hours, minutes, seconds]; [duration setStringValue:trackDurationString]; sleep(1); }} Any help would be much appreciated, thanks in advanced, Sami.

    Read the article

  • Setting QTMovie attributes

    - by Josh Matthews
    I'm trying to create a QTVR movie via QTKit, and I've got all the frames in the movie. However, setting the attributes necessary doesn't seem to be having any effect. For example: NSNumber *val = [NSNumber numberWithBool:YES]; [fMovie setAttribute:val forKey:QTMovieIsInteractiveAttribute]; val = [NSNumber numberWithBool:NO]; [fMovie setAttribute:val forKey:QTMovieIsLinearAttribute]; If I then get the value of these attributes, they come up as NO and YES, respectively. The movie is editable, so I can't understand what I'm doing wrong here. How can I ensure that the attributes will actually change?

    Read the article

  • How to use NSObject subclass?

    - by Jon
    So I've created a subclass of NSObject called Query @interface Query : NSObject @property (nonatomic, assign) NSNumber *weight; @property (nonatomic, assign) NSNumber *bodyFat; @property (nonatomic, assign) NSNumber *activityLevel; @end Is this correct for setting the object's property? In VC1: BodyFatViewController *aViewController = [[BodyFatViewController alloc]init]; aViewController.query = self.query; [self.navigationController pushViewController:aViewController animated:YES]; In VC2: - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { Query *anQuery = [[Query alloc]init]; anQuery.bodyFat = [self.bodyFatArray objectAtIndex:row]; anQuery.weight = self.query.weight; self.query = anQuery; }

    Read the article

  • Display selectedAnnotation info

    - by elife_iPhone
    When I use this: - (void)mapView:(MKMapView *)myMapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { NSLog(@"SelectedAnnotations is %@", myMapView.selectedAnnotations); } It Displays this in the log. "<Annotation: 0x586cdb0>" Now this is a weird question, but how do I get the info from this Annotation? I have lost my mind. This is what is in the annotation. myAnnotation = [[Annotation alloc] init]; myAnnotation.dealName=[NSString stringWithFormat:@"%@",[tempValue objectForKey:@"name"]]; myAnnotation.subName=[NSString stringWithFormat:@"Price: $%@",[tempValue objectForKey:@"price"]]; myAnnotation.latitude = [NSNumber numberWithDouble:[[tempValue objectForKey:@"dealLatitude"] doubleValue]]; myAnnotation.longitude = [NSNumber numberWithDouble:[[tempValue objectForKey:@"dealLongitude"] doubleValue]]; myAnnotation.dealId = [NSNumber numberWithInt:[ [tempValue objectForKey:@"dId"] intValue ]]; Thanks for your help.

    Read the article

  • AVAudioPlayer crash after playing from an AVAudioRecorder

    - by munchine
    I've got a button the user tap to start recording and tap again to stop. When it stop I want the recorded voice 'echo' back so the user can hear what was recorded. This works fine the first time. If I hit the button for the third time, it starts a new recording and when I hit stop it crashes with EXC_BAD_ACCESS. - (IBAction) readToMeTapped { if(recording) { recording = NO; [readToMeButton setTitle:@"Stop Recording" forState: UIControlStateNormal ]; NSMutableDictionary *recordSetting = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithFloat: 44100.0], AVSampleRateKey, [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, [NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey, nil]; // Create a new dated file NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0]; NSString *caldate = [now description]; recordedTmpFile = [NSURL fileURLWithPath:[[NSString stringWithFormat:@"%@/%@.caf", DOCUMENTS_FOLDER, caldate] retain]]; error = nil; recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error]; [recordSetting release]; if(!recorder){ NSLog(@"recorder: %@ %d %@", [error domain], [error code], [[error userInfo] description]); UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Warning" message: [error localizedDescription] delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; return; } NSLog(@"Using File called: %@",recordedTmpFile); //Setup the recorder to use this file and record to it. [recorder setDelegate:self]; [recorder prepareToRecord]; [recorder recordForDuration:(NSTimeInterval) 5]; //recording for a limited time } else { // it crashes the second time it gets here! recording = YES; NSLog(@"Recording YES Using File called: %@",recordedTmpFile); [readToMeButton setTitle:@"Start Recording" forState:UIControlStateNormal ]; [recorder stop]; //Stop the recorder. //playback recording AVAudioPlayer * newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordedTmpFile error:&error]; [recordedTmpFile release]; self.aPlayer = newPlayer; [newPlayer release]; [aPlayer setDelegate:self]; [aPlayer prepareToPlay]; [aPlayer play]; } } - (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)sender successfully:(BOOL)flag { NSLog (@"audioRecorderDidFinishRecording:successfully:"); [recorder release]; recorder = nil; } Checking the debugger, it flags the error here @synthesize aPlayer, recorder; This is the part I don't understand. I thought it may have something to do with releasing memory but I've been careful. Have I missed something?

    Read the article

  • How can I pass latitude and longitude values from UIViewController to MKMapView?

    - by jerincbus
    I have a detail view that includes three UIButtons, each of which pushes a different view on to the stack. One of the buttons is connected to a MKMapView. When that button is pushed I need to send the latitude and longitude variables from the detail view to the map view. I'm trying to add the string declaration in the IBAction: - (IBAction)goToMapView { MapViewController *mapController = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil]; mapController.mapAddress = self.address; mapController.mapTitle = self.Title; mapController.mapLat = self.lat; mapController.mapLng = self.lng; //Push the new view on the stack [[self navigationController] pushViewController:mapController animated:YES]; [mapController release]; //mapController = nil; } And on my MapViewController.h file I have: #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> #import "DetailViewController.h" #import "CourseAnnotation.h" @class CourseAnnotation; @interface MapViewController : UIViewController <MKMapViewDelegate> { IBOutlet MKMapView *mapView; NSString *mapAddress; NSString *mapTitle; NSNumber *mapLat; NSNumber *mapLng; } @property (nonatomic, retain) IBOutlet MKMapView *mapView; @property (nonatomic, retain) NSString *mapAddress; @property (nonatomic, retain) NSString *mapTitle; @property (nonatomic, retain) NSNumber *mapLat; @property (nonatomic, retain) NSNumber *mapLng; @end And on the pertinent parts of the MapViewController.m file I have: @synthesize mapView, mapAddress, mapTitle, mapLat, mapLng; - (void)viewDidLoad { [super viewDidLoad]; [mapView setMapType:MKMapTypeStandard]; [mapView setZoomEnabled:YES]; [mapView setScrollEnabled:YES]; MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; region.center.latitude = mapLat; //40.105085; region.center.longitude = mapLng; //-83.005237; region.span.longitudeDelta = 0.01f; region.span.latitudeDelta = 0.01f; [mapView setRegion:region animated:YES]; [mapView setDelegate:self]; CourseAnnotation *ann = [[CourseAnnotation alloc] init]; ann.title = mapTitle; ann.subtitle = mapAddress; ann.coordinate = region.center; [mapView addAnnotation:ann]; } But I get this when I try to build: 'error: incompatible types in assignment' for both lat and lng variables. So my questions are am I going about passing the variables from one view to another the right way? And does the MKMapView accept latitude and longitude as a string or a number?

    Read the article

  • AVAudioPlayer crash after playing from an AVAudioRecord

    - by munchine
    I've got a button the user tap to start recording and tap again to stop. When it stop I want the recorded voice 'echo' back so the user can hear what was recorded. This works fine the first time. If I hit the button for the third time, it starts a new recording and when I hit stop it crashes with EXC_BAD_ACCESS. - (IBAction) readToMeTapped { if(recording) { recording = NO; [readToMeButton setTitle:@"Stop Recording" forState: UIControlStateNormal ]; NSMutableDictionary *recordSetting = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithFloat: 44100.0], AVSampleRateKey, [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, [NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey, nil]; // Create a new dated file NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0]; NSString *caldate = [now description]; recordedTmpFile = [NSURL fileURLWithPath:[[NSString stringWithFormat:@"%@/%@.caf", DOCUMENTS_FOLDER, caldate] retain]]; error = nil; recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error]; if(!recorder){ NSLog(@"recorder: %@ %d %@", [error domain], [error code], [[error userInfo] description]); UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Warning" message: [error localizedDescription] delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; return; } NSLog(@"Using File called: %@",recordedTmpFile); //Setup the recorder to use this file and record to it. [recorder setDelegate:self]; [recorder prepareToRecord]; [recorder recordForDuration:(NSTimeInterval) 5]; //recording for a limited time } else { // it crashes the second time it gets here! recording = YES; NSLog(@"Recording YES Using File called: %@",recordedTmpFile); [readToMeButton setTitle:@"Start Recording" forState:UIControlStateNormal ]; [recorder stop]; //Stop the recorder. //playback recording AVAudioPlayer * newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordedTmpFile error:&error]; [recordedTmpFile release]; self.aPlayer = newPlayer; [newPlayer release]; [aPlayer setDelegate:self]; [aPlayer prepareToPlay]; [aPlayer play]; } } - (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)sender successfully:(BOOL)flag { NSLog (@"audioRecorderDidFinishRecording:successfully:"); [recorder release]; recorder = nil; } Checking the debugger, it flags the error here @synthesize aPlayer, recorder; This is the part I don't understand. I thought it may have something to do with releasing memory but I've been careful. Have I missed something?

    Read the article

  • How can I get image data from QTKit without color or gamma correction in Snow Leopard?

    - by Nick Haddad
    Since Snow Leopard, QTKit is now returning color corrected image data from functions like QTMovies frameImageAtTime:withAttributes:error:. Given an uncompressed AVI file, the same image data is displayed with larger pixel values in Snow Leopard vs. Leopard. Currently I'm using frameImageAtTime to get an NSImage, then ask for the tiffRepresentation of that image. After doing this, pixel values are slightly higher in Snow Leopard. For example, a file with the following pixel value in Leopard: [0 180 0] Now has a pixel value like: [0 192 0] Is there any way to ask a QTMovie for video frames that are not color corrected? Should I be asking for a CGImageRef, CIImage, or CVPixelBufferRef instead? Is there a way to disable color correction altogether prior to reading in the video files? I've attempted to work around this issue by drawing into a NSBitmapImageRep with the NSCalibratedColroSpace, but that only gets my part of the way there: // Create a movie NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys : nsFileName, QTMovieFileNameAttribute, [NSNumber numberWithBool:NO], QTMovieOpenAsyncOKAttribute, [NSNumber numberWithBool:NO], QTMovieLoopsAttribute, [NSNumber numberWithBool:NO], QTMovieLoopsBackAndForthAttribute, (id)nil]; _theMovie = [[QTMovie alloc] initWithAttributes:dict error:&error]; // .... NSMutableDictionary *imageAttributes = [NSMutableDictionary dictionary]; [imageAttributes setObject:QTMovieFrameImageTypeNSImage forKey:QTMovieFrameImageType]; [imageAttributes setObject:[NSArray arrayWithObject:@"NSBitmapImageRep"] forKey: QTMovieFrameImageRepresentationsType]; [imageAttributes setObject:[NSNumber numberWithBool:YES] forKey:QTMovieFrameImageHighQuality]; NSError* err = nil; NSImage* image = (NSImage*)[_theMovie frameImageAtTime:frameTime withAttributes:imageAttributes error:&err]; // copy NSImage into an NSBitmapImageRep (Objective-C) NSBitmapImageRep* bitmap = [[image representations] objectAtIndex:0]; // Draw into a colorspace we know about NSBitmapImageRep *bitmapWhoseFormatIKnow = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:getWidth() pixelsHigh:getHeight() bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bitmapFormat:0 bytesPerRow:(getWidth() * 4) bitsPerPixel:32]; [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:bitmapWhoseFormatIKnow]]; [bitmap draw]; [NSGraphicsContext restoreGraphicsState]; This does convert back to a 'Non color corrected' colorspace, but the color values NOT are exactly the same as what is stored in the Uncompressed AVI files we are testing with. Also this is much less efficient because it is converting from RGB - "Device RGB" - RGB. Also, I am working in a 64-bit application, so dropping down to the Quicktime-C API is not an option. Thanks for your help.

    Read the article

  • get current selected button cell placed inside tableview using cocoa

    - by Swati
    hi i have a NSTableView i have two columns A and B B contains some data A contains custom button the button is added to column A using this: Below code is placed inside awakeFromNib method NSButtonCell *buttonCell = [[[NSButtonCell alloc] init] autorelease]; [buttonCell setBordered:NO]; [buttonCell setImagePosition:NSImageOnly]; [buttonCell setButtonType:NSMomentaryChangeButton]; [buttonCell setImage:[NSImage imageNamed:@"uncheck.png"]]; [buttonCell setSelectable:TRUE]; [buttonCell setTag:100]; [buttonCell setTarget:self]; [buttonCell setAction:@selector(selectButtonsForDeletion:)]; [[myTable tableColumnWithIdentifier:@"EditIdentifier"] setDataCell:buttonCell]; Some code in display cell of nstableview: -(void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex { if(tableView == myTable) { if([[tableColumn identifier] isEqualToString:@"DataIdentifier"]) { } else if([[tableColumn identifier] isEqualToString:@"EditIdentifier"]) { NSButtonCell *zCell = (NSButtonCell *)cell; [zCell setTag:rowIndex]; [zCell setTitle:@"abc"]; [zCell setTarget:self]; [zCell setAction:@selector(selectButtonsForDeletion:)]; } } } now i want that when i click on the button the image of button cell gets changed as well as i want to do some coding. When button gets clicked then by default the tableView's reference gets passed. How can i get the button cell reference i looked here for similar problem: Cocoa: how to nest a button inside a Table View cell? but i am unable to add button inside column of NSTableView. How i change the image: - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row; { if(tableView == myTable) { if([[tableColumn identifier] isEqualToString:@"EditIdentifier"]) { NSButtonCell *aCell = (NSButtonCell *)[[tableView tableColumnWithIdentifier:@"EditIdentifier"] dataCellForRow:row]; NSInteger index = [[aCell title]intValue]; if([self.selectedIndexesArray count]>0) { if(![self.selectedIndexesArray containsObject:[NSNumber numberWithInt:index]]) { [aCell setImage:[NSImage imageNamed:@"check.png"]]; [self.selectedIndexesArray addObject:[NSNumber numberWithInt:index]]; } else { [aCell setImage:[NSImage imageNamed:@"uncheck.png"]]; [self.selectedIndexesArray removeObjectAtIndex:[selectedIndexesArray indexOfObject:[NSNumber numberWithInt:index]]]; } } else { [aCell setImage:[NSImage imageNamed:@"check.png"]]; [self.selectedIndexesArray addObject:[NSNumber numberWithInt:index]]; } } } } I have debugged the code and found that proper tag and titles are passed but image applies on more than one button cell, this is too very irregular. cant understand how its working!!! Any suggestions what am i doing wrong??

    Read the article

  • iPhone: how to keep integer value on UILabel

    - by Nandakishore
    i am working on Twitter on iPhone now i have to keep the count of Friend, Tweets, Followers etc on UILabel how to work with this (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier { NSLog(@"User Info Received: %@", userInfo); // userInfo contains all user details like userName, screenName, count of Friends, Followers, Following, Status Count etc NSLog(@"User Info Received: %d", [userInfo count]); NSMutableDictionary *profileData = [userInfo objectAtIndex:0]; //converting userInfo array into profileData dictionary lblUserName.text = [profileData objectForKey:@"name"]; // lblUserName is UILabel, userName keeping on Label lblLocation.text = [profileData objectForKey:@"location"]; // lblLocation is UILabel, Location keeping on Label lblDescription.text = [profileData objectForKey:@"description"]; // lblDescription is UILabel, Location keeping on Label /////* Up to here all working but how to Keep integer value on UILabel *///// lblFolCount = (NSNumber *)[profileData objectForKey:@"followers_count"]; //how to keep user Followers Count on UILable lblFavCount = (NSNumber *)[profileData objectForKey:@"favourites_count"]; //how to keep user Followers Count on UILable lblStatusCount = (NSNumber *) [profileData objectForKey:@"statuses_count"]; //how to keep user statuses count on UILable lblFriends = (NSNumber *) [profileData objectForKey:@"friends_count"]; //how to keep user friends count on UILable } ////**This info Display on debugger console*/////// ////NSLog(@"User Info Received: %@", userInfo); // by this we get info on debugger console User Info Received: ( { "created_at" = "Tue Nov 02 14:42:42 +0000 2010"; description = "being honest"; favorited = false; "favourites_count" = 0; "followers_count" = 5; "friends_count" = 21; "listed_count" = 0; location = Chennai; name = "nanda kishore reddyv"; "profile_background_color" = EDECE9; "profile_background_image_url" = "http://a2.twimg.com/a/1292975674/images/themes/theme3/bg.gif"; "profile_background_tile" = false; "profile_image_url" = "http://a2.twimg.com/a/1292975674/images/default_profile_6_normal.png"; "retweet_count" = 0; "screen_name" = velugotinanda; source = "<a href=\"http://www.icodeblog.com\" rel=\"nofollow\">iCodeBlog Oauth Demo</a>"; status = "Mon Dec 27 09:22:44 +0000 2010"; "statuses_count" = 15; "time_zone" = "Indiana (East)"; verified = false; } ) 2011-01-01 10:38:29.460 IdeaTweet[471:207] User Info Received: 1 Thanks YOU can you tell me how to Keep integer Value on UILabel

    Read the article

  • Can't record or play with a simple recorder?

    - by user1280535
    I have 2 classes, a record and a player. In my main scene, I create an instance of them and play and record. But, as I see, it only records and somehow does not play (the file is not there!) Here is the code for both : -(void)record { NSArray *dirPaths; NSString *docsDir; NSString *sound= @"sound0.caf" ; dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) ; docsDir = [dirPaths objectAtIndex:0]; NSString *soundFilePath = [docsDir stringByAppendingPathComponent:sound]; NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath]; NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithFloat: 44100.0], AVSampleRateKey, [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, [NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey, nil]; NSError *error; myRecorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL settings:settings error:&error]; if (myRecorder) { NSLog(@"rec"); [myRecorder prepareToRecord]; myRecorder.meteringEnabled = YES; [myRecorder record]; } else NSLog( @"error" ); } I can see the log of rec. -(void)play { NSArray *dirPaths; NSString *docsDir; dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; NSString *soundFilePath1 = @"sound0.caf" ; NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath1]; BOOL isMyFileThere = [[NSFileManager defaultManager] fileExistsAtPath:soundFilePath1]; if(isMyFileThere) { NSLog(@"PLAY"); avPlayer1 = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:NULL]; avPlayer1.volume = 8.0; avPlayer1.delegate = self; [avPlayer1 play]; } } I DONT SEE THE LOG OF PLAY ! I call them both with: recInst=[recorder alloc]; //to rec [recInst record]; plyInst=[player alloc]; //play [plyInst play]; and to stop the recorder: - (void)stopRecorder { NSLog(@"stopRecordings"); [myRecorder stop]; //[myRecorder release]; } What's wrong here? Thanks.

    Read the article

  • iPhone:How to make an integer array and store values in Obj-C?

    - by user187532
    Hi, I want to know a simple thing, which i couldn't get it is that i want to store 10 values in an integer array dynamically and then i have to check that stored values and compared with the current values whether it is same or not in some other condition. Initially i tried same like C array, int temp[10], but seems to be that is not possible to set and get method, then i tried NSNumber like below, In AppDelagate file, NSMutableArray *reqID; @property (nonatomic,readwrite) NSMutableArray * reqID; @synthesize reqID; ........................ ........................ ........................ In Some other file, int rd = (1+arc4random() % [arr count]); [myDelagate.reqID addObject:[NSNumber numberWithUnsignedInteger:rd]]; then i need to check, for (int i=0; i<10; i++) { NSUInteger anInt = [[amyDelagate.reqID objectAtIndex:i] unsignedIntegerValue]; if ( anInt==rd ) { rd = (1+arc4random() % [arr count]); break; } } [myDelagate.reqID addObject:[NSNumber numberWithUnsignedInteger:rd]]; But it doesn' work as expected, i.e array value doesn't give proper value. i don't know how to use integer array in Obj-C and handle it to access later etc. Could someone please explian me?

    Read the article

  • Need help with animation on iPhone

    - by Arun Ravindran
    I'm working on an animated clock application for the iPhone, and I have to pivot all the 3 nodes in the view, which I have obtained in the following code: [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; clockarm.layer.anchorPoint = CGPointMake(0.0, 0.0); [CATransaction commit]; [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanFalse forKey:kCATransactionDisableActions]; [CATransaction setValue:[NSNumber numberWithFloat:50.0] forKey:kCATransactionAnimationDuration]; CABasicAnimation *animation; animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.fromValue = [NSNumber numberWithFloat:-60.0]; animation.toValue = [NSNumber numberWithFloat:2 * M_PI]; animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear]; animation.delegate = self; [clockarm.layer addAnimation:animation forKey:@"rotationAnimation"]; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; [CATransaction commit]; The problem it's just rotating once, ie. only 360 degree and then stopping. I want to raotate the needles indefinitely. How would I do that?

    Read the article

  • Problem with NSUserDefaults and deallocated Instance

    - by Peter A
    Hi, I'm having a problem with NSUserDefaults. I've followed the steps in the books as closely as I can for my app, but still get the same problem. I am getting a *** -[NSUserDefaults integerForKey:]: message sent to deallocated instance 0x3b375a0 error when I try and load in the settings. Here is the code that I have, it is in the App Delegate class. - (void)applicationDidFinishLaunching:(UIApplication *)application { recordingController = [[RecordingTableViewController alloc] initWithStyle:UITableViewStylePlain]; [recordingController retain]; // Add the tab bar controller's current view as a subview of the window [window addSubview:tabBarController.view]; [self loadSettings]; } -(void)loadSettings { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSNumber loop = [defaults objectForKey:@"loop_preference"]; NSNumber play = [defaults objectForKey:@"play_me_preference"]; NSNumber volume = [defaults objectForKey:@"volume_preference"]; } As you can see I am not trying to do anything with the values yet, but I get the error on the line reading in the loop preference. I also get it if I try and read an NSString. Any suggestions would be greatly appreciated. Thanks Peter

    Read the article

  • Wordpress XML-RPC call from Objective C: wp.newComment

    - by radesix
    I'm using Eric Czarny's Cocoa XML-RPC framework to make a call to the Wordpress API's. I've downloaded the sample app from Wordpress which gives some good examples. Unfortunately the good examples are for every call EXCEPT wp.newComment. I'm trying to post a comment using the code below and I keep getting an error with a localized description that tells me to check my input parameters. I've checked and rechecked and I don't understand what is wrong. Any ideas? NSDictionary *commentStructure = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:0], @"comment_parent", @"xmlrpc anonymous comments plugin now enabled", @"content", @"Test Author", @"author", @"http://iphone.someurl.com", @"author_url", @"[email protected]", @"author_email", nil]; NSArray *args = [NSArray arrayWithObjects:[NSNumber numberWithInt:0], @"", @"", [NSNumber numberWithInt:[self.parentFeedItem.postID intValue]], commentStructure, nil]; // the param(s) NSString *server = [[[NSString alloc] initWithString:@"http://www.someurl.com/xmlrpc.php"] autorelease]; // the server NSString *method = [[[NSString alloc] initWithString:@"wp.newComment"] autorelease]; // the method XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithHost:[NSURL URLWithString:server]]; [request setMethod:method withObjects:args]; id response = [self executeXMLRPCRequest:request]; [request release]; if( [response isKindOfClass:[NSError class]] ) { //return nil; NSLog(@"There was a problem"); NSLog([response localizedDescription]); }

    Read the article

  • core-plot barchart does not work!!

    - by user355068
    Hello~ I try to draw bar chart!! numberForPlot is not good work, only CPBarPlotFieldBarLength set. -(NSNumber *)numberForPlot: (CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index { NSDecimalNumber *num = nil; NSString *key = (fieldEnum == CPScatterPlotFieldX) ? @"x" : @"y"; if ( [plot isKindOfClass:[CPBarPlot class]] ) { switch ( fieldEnum ) { NSLog(@"fieldEnum = %d",fieldEnum); case CPBarPlotFieldBarLocation: num = (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInteger:index]; NSLog(@"CPBarPlotFieldBarLocation return num = %@",num); break; case CPBarPlotFieldBarLength: num = (NSDecimalNumber *)[NSDecimalNumber numberWithUnsignedInteger: (index+1)*(index+1)]; if ( [plot.identifier isEqual:Plot3Identity] ) num = [[self.ExForPlot objectAtIndex:index] valueForKey:key]; NSLog(@"CPBarPlotFieldBarLength return num = %@",num); break; } } else { NSLog(@"...??.."); } return num; } # LOG 2010-06-01 02:43:19.424 myHealth[5071:207] CPBarPlotFieldBarLength return num = 0 2010-06-01 02:43:19.425 myHealth[5071:207] CPBarPlotFieldBarLength return num = 0 2010-06-01 02:43:19.425 myHealth[5071:207] CPBarPlotFieldBarLength return num = 30 # EXPlot set // Add some initial data NSMutableArray *contentArray = [NSMutableArray arrayWithCapacity:100]; int prevWeight = 0; int prevBmi = 0 ; if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) { while (sqlite3_step(statement)==SQLITE_ROW) { id x = [NSNumber numberWithInt:graphTimeStamp]; id y = [NSNumber numberWithInt:sqlite3_column_int(statement, 2)]; [contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x, @"x", y, @"y", nil]]; } self.ExForPlot = contentArray;

    Read the article

  • Display subclass data in XCode Expression window

    - by Nick VanderPyle
    I'm debugging an iPhone application I've written using XCode 3.2 and I cannot view the relevant public properties of an object I pull from Core Data. When I watch the object in the Expressions window it only displays the data from the base NSManagedObject. I'd like to see the properties that are on the subclass, not the superclass. If it helps, here's some of the code I'm using. Settings is a subclass of NSManagedObject. I created it using XCode's built-in modeler. Declared like: @interface Settings : NSManagedObject { } @property (nonatomic, retain) NSNumber * hasNews; @property (nonatomic, retain) NSString * logoUrl; @property (nonatomic, retain) NSNumber * hasPaymentGateway; @property (nonatomic, retain) NSString * customerCode; ... In the interface of my controller I have: Settings *settings; I populate settings with: settings = (Settings *)[NSEntityDescription insertNewObjectForEntityForName:@"Settings" inManagedObjectContext:UIAppManagedObjectContext()]; I then set the properties like: settings.hasNews = [NSNumber numberWithBool:TRUE]; I've tried casting settings as (Settings *) in the Expression window but that doesn't help. All I see are the properties to NSManagedObject. I'm using NSLog but would rather not.

    Read the article

  • iPhone OS: Why is my managedModelObject not complying with Key Value Coding?

    - by nickthedude
    Ok so I'm trying to build this stat tracker for my app and I have built a data model object called statTracker that keeps track of all the stuff I want it to. I can set and retrieve values using the selectors, but if I try and use KVC (ie setValue: forKey: ) everything goes bad and says my StatTracker class is not KVC compliant: valueForUndefinedKey:]: the entity StatTracker is not key value coding-compliant for the key "timesLauched".' 2010-05-18 15:55:08.573 here's the code that is triggering it: NSArray *statTrackerArray = [[NSArray alloc] init]; statTrackerArray = [[CoreDataSingleton sharedCoreDataSingleton] getStatTracker]; NSNumber *number1 = [[NSNumber alloc] init]; number1 = [NSNumber numberWithInt:(1 + [[(StatTracker *)[statTrackerArray objectAtIndex:0] valueForKey:@"timesLauched"] intValue])]; [(StatTracker *)[statTrackerArray objectAtIndex:0] setValue:number1 forKey:@"timesLaunched" ]; NSError *error; if (![[[CoreDataSingleton sharedCoreDataSingleton] managedObjectContext] save:&error]) { NSLog(@"error writing to db"); } Not sure if this is enough code for you folks let me know what you need if you do need more. This would be so sweet if I could use KVC because I could then abstract all this stat tracking stuff into a single method call with a string argument for the value in question. At least that is what I hope to accomplish here. I'm actually now understanding the power of KVC but now I'm just trying to figure out how to make it work. Thanks! Nick

    Read the article

  • Why is Core Data not persisting these changes to disk?

    - by scott
    I added a new entity to my model and it loads fine but no changes made in memory get persisted to disk. My values set on the car object work fine in memory but aren't getting persisted to disk on hitting the home button (in simulator). I am using almost exactly the same code on another entity in my application and its values persist to disk fine (core data - sqlite3); Does anyone have a clue what I'm overlooking here? Car is the managed object, cars in an NSMutableArray of car objects and Car is the entity and Visible is the attribute on the entity which I am trying to set. Thanks for you assistance. Scott - (void)viewDidLoad { myAppDelegate* appDelegate = (myAppDelegate*)[[UIApplication sharedApplication] delegate]; NSManagedObjectContext* managedObjectContex = appDelegate.managedObjectContext; NSFetchRequest* request = [[NSFetchRequest alloc] init]; NSEntityDescription* entity = [NSEntityDescription entityForName:@"Car" inManagedObjectContext:managedObjectContex]; [request setEntity:entity]; NSSortDescriptor* sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"Name" ascending:YES]; NSArray* sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [sortDescriptors release]; [sortDescriptor release]; NSError* error = nil; cars = [[managedObjectContex executeFetchRequest:request error:&error] mutableCopy]; if (cars == nil) { NSLog(@"Can't load the Cars data! Error: %@, %@", error, [error userInfo]); } [request release]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { Car* car = [cars objectAtIndex:indexPath.row]; if (car.Visible == [NSNumber numberWithBool:YES]) { car.Visible = [NSNumber numberWithBool:NO]; [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone; } else { car.Visible = [NSNumber numberWithBool:YES]; [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; } }

    Read the article

  • Altering ManagedObjects In NSArray

    - by Garry
    I have an entity called 'Job' with two boolean attributes named 'completed' and 'logged'. I am trying to retrieve all completed jobs that have not been logged at app start-up and change them to logged. I'm able to get all the completed but unlogged jobs with this fetchRequest: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(completed == %@ && logged == %@)", [NSNumber numberWithBool:YES], [NSNumber numberWithBool:NO]]; I'm then assigning this predicate to a fetchRequest and calling the [managedObjectContext executeFetchRequest:fetchRequest] method to get an array of all Job entities that meet this criteria. This seems to work fine and is returning the correct number of jobs. What I've been trying to do is loop through the NSArray returned, set the logged attribute to YES and then save. This seems to complete and doesn't return any errors but the changes are not persisted when the application quits. Where am I going wrong? [fetchRequest setPredicate:predicate]; NSError error; NSArray jobsToLog = [managedObjectContext executeFetchRequest:fetchRequest error:&error]; if ([jobsToLog count] > 0) { for (int i = 0; i < [jobsToLog count] - 1; i++) { [[jobsToLog objectAtIndex:i] setLogged:[NSNumber numberWithBool:YES]]; // Commit the changes made to disk error = nil; if (![managedObjectContext save:&error]) { // An error occurred } } } Thanks in anticipation,

    Read the article

  • Accessing Instance Variables from NSTimer selector

    - by Timbo
    Firstly newbie question: What's the difference between a selector and a method? Secondly newbie question (who would have thought): I need to loop some code based on instance variables and pause between loops until some condition (of course based on instance variables) is met. I've looked at sleep, I've looked at NSThread. In both discussions working through those options many asked why don't I use NSTimer, so here I am. Ok so it's simple enough to get a method (selector? ) to fire on a schedule. Problem I have is that I don't know how to see instance variables I've set up outside the timer from within the code NSTimer fires. I need to see those variables from the NSTimer selector code as I 1) will be updating their values and 2) will set labels based on those values. Here's some code that shows the concept… eventually I'd invalidate the timers based on myVariable too, however I've excluded that for code clarity. MyClass *aMyClassInstance = [MyClass new]; [aMyClassInstance setMyVariable:0]; [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(doStuff) userInfo:nil repeats:YES]; [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(doSomeOtherStuff) userInfo:nil repeats:YES]; - (void) doStuff { [aMyClassInstance setMyVariable:11]; // don't actually have access to set aMyClassInstance.myVariable [self updateSomeUILabel:[NSNumber numberWithInt:aMyClassInstance.myVariable]]; // don't actually have access to aMyClassInstance.myVariable } - (void) doSomeOtherStuff { [aMyClassInstance setMyVariable:22]; // don't actually have access to set aMyClassInstance.myVariable [self updateSomeUILabel:[NSNumber numberWithInt:aMyClassInstance.myVariable]]; // don't actually have access to aMyClassInstance.myVariable } - (void) updateSomeUILabel:(NSNumber *)arg{ int value = [arg intValue]; someUILabel.text = [NSString stringWithFormat:@"myVariable = %d", value]; // Updates the UI with new instance variable values }

    Read the article

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