Search Results

Search found 657 results on 27 pages for 'nsurl'.

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

  • iPhone Core Data Lightweight Migration error: reason = "Can't find model for source store";

    - by tul697
    Steps taken: 1. Added Data Model version: Changed my XXX.xcdatamodel to XXX.xcdatamodeId with Design - Data Model - Add Model Version. Set the new XXX 2.xcdatamodel as current version Added an attribute to XXX 2.xcdatamodel Added NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption like most tutorials, I added the option in the addPersistentStoreWithType. ran the code and I got this error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134130 UserInfo=0x146bb80 "Operation could not be completed. (Cocoa error 134130.)", { URL = file://localhost/Users/tleung/Library/Application%20Support/iPhone%20Simulator/3.0/Applications/B585CDFC-17C3-4A44-84E2-0B75893C46B8/Documents/favorites.sqlite; metadata = { NSPersistenceFrameworkVersion = 241; NSStoreModelVersionHashes = { City = <70ea1f9f aaa9af29 52d2bfe4 3071d97f 8224f765 d69928d5 e5844120 52742a35; StationStore = <40d8093a 1d7d00ec 178b4374 36dfc137 ccfa3a88 87e2d467 69e8ae7e d4c49dbb; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = ( ); NSStoreType = SQLite; NSStoreUUID = "9DD342A6-1F68-4997-A097-096DC96D7BF3"; }; reason = "Can't find model for source store"; } I've also tried NSString *path = [[NSBundle mainBundle] pathForResource:@"YOURDB" ofType:@"momd"]; NSURL *momURL = [NSURL fileURLWithPath:path]; managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:momURL]; as suggested by other posts with no success. It seems that it can't find ANY of my models... anyone have any idea?

    Read the article

  • Encoding issue: Cocoa Error 261?

    - by Attacus
    So I'm fetching a JSON string from a php script in my iPhone app using: NSURL *baseURL = [NSURL URLWithString:@"test.php"]; NSError *encodeError = [[NSError alloc] init]; NSString *jsonString = [NSString stringWithContentsOfURL:baseURL encoding:NSUTF8StringEncoding error:&encodeError]; NSLog(@"Error: %@", [encodeError localizedDescription]); NSLog(@"STRING: %@", jsonString); The JSON string validates when I test the output. Now I'm having an encoding issue. When I fetch a single echo'd line such as: { "testKey":"é" } (I'm aware I could\should be using NSUrlConnection for asynchronous fetching of data, but at this point in the app development, I don't really need it.) The JSON parser works fine and I am able to create a valid JSON object. However, when I fetch my 2MB JSON string, I get presented with: Error: Operation could not be completed. (Cocoa error 261.) and a Null string. My PHP file is UTF8 itself and I am not using utf8_encode() because that seems to double encode the data since I'm already pulling the data as NSUTF8StringEncoding. Either way, in my single-echo test, it's the approach that allowed me to successfully log \ASDAS style UTF8 escapes when building the JSON object. What could be causing the error in the case of the larger string? Also, I'm not sure if it makes a difference, but I'm using the php function addslashes() on my parsed php data to account for quotes and such when building the JSON string.

    Read the article

  • Creating Drill-Down Detail UITableView from JSON NSDictionary

    - by Michael Robinson
    I'm have a load of trouble finding out how to do this, I want to show this in a UITableDetailView (Drill-Down style) with each item in a different cell. All of the things I've read all show how to load a single image on the detail instead of showing as a UITableView. Does the dictionary have to have "children" in order to load correctly? Here is the code for the first view creating *dict from the JSON rowsArray. I guess what I'm looking for is what to put in the FollowingDetailViewController.m to see the rest of *dict contents, so when selecting a row, it loads the rest of the *dict. I have rowsArray coming back as follows: '{ loginName = Johnson; memberid = 39; name = Kris; age = ;}, etc,etc... Thanks, // SET UP TABLE & CELLS - (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] autorelease]; } NSDictionary *dict = [rowsArray objectAtIndex: indexPath.row]; cell.textLabel.text = [dict objectForKey:@"name"]; cell.detailTextLabel.text = [dict objectForKey:@"loginName"]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - (void)viewDidLoad { [super viewDidLoad]; //GET JSON FROM WEBSERVICES: NSURL *url = [NSURL URLWithString:@"http://10.0.1.8/~imac/iphone/jsontest.php"]; NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url]; NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSError *error = nil; NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error]; if (dict) { rowsArray = [dict objectForKey:@"member"]; [rowsArray retain]; } [jsonreturn release]; } //GO TO DETAIL VIEW: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { FollowingDetailViewController *aFollowDetail = [[FollowingDetailViewController alloc] initWithNibName:@"FollowingDetailView" bundle:nil]; [self.navigationController pushViewController:aFollowDetail animated:YES]; }

    Read the article

  • iPhone - openAL stops playing if I record with AVAudioRecorder

    - by Oscar Peli
    Hi there, this is an iPhone-related question: I use openAL to play some sound (I have to manage gain, pitch, etc.). I want to record what I'm playing and I use AVAudioRecorder but when I "prepareToRecord" openAL stops to play audio. What's the problem? Here is the record IBAction I use: - (IBAction) record: (id) sender { NSError *error; NSMutableDictionary *settings = [NSMutableDictionary dictionary]; [settings setValue: [NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey]; [settings setValue: [NSNumber numberWithFloat:8000.0] forKey:AVSampleRateKey]; [settings setValue: [NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey]; [settings setValue: [NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; [settings setValue: [NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey]; [settings setValue: [NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey]; NSURL *url = [NSURL fileURLWithPath:FILEPATH]; self.recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error]; self.recorder.delegate = self; self.recorder.meteringEnabled = YES; [self.recorder prepareToRecord]; [self.recorder record]; } Thanks

    Read the article

  • Embed Youtube in UIWebView behind transparent img. Wmode transparent and z-index doesn't work

    - by Allisone
    I'm using this code: - (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame { NSString *embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: black;\ }\ #container{\ position: relative;\ z-index:1;\ }\ #video,#videoc{\ position:absolute;\ z-index: 1;\ border: none;\ }\ #tv{\ background: transparent url(tv.png) no-repeat;\ width: 320px;\ height: 205px;\ position: absolute;\ top: 0;\ z-index: 999;\ }\ </style>\ </head><body style=\"margin:0\">\ <div id=\"tv\"></div>\ <object id=\"videoc\" width=\"240\" height=\"160\">\ <param name=\"movie\" value=\"%@\"></param>\ <param name=\"wmode\" value=\"transparent\"></param>\ <embed wmode=\"transparent\" id=\"video\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"240\" height=\"160\"></embed>\ </object>\ </body></html>"; NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path]; NSString *html = [NSString stringWithFormat:embedHTML, urlString,urlString]; UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame]; [videoView loadHTMLString:html baseURL:baseURL]; [self.view addSubview:videoView]; [videoView release]; } Its the first time that I use UIWebView and the first time that I use video in iPhone. The video plays, so that's working BUT: I want to have an old school tv (round corners) in foreground with switches and so on. The tv is an image with transparent pixels in the middle, so that a video lying behind the tv will shine through as if the video would be shown on the tv. But first of all the video has a border that I can't remove and second it's always in the foreground. In Safari and in Firefox and Mac it's working. So is it an iPhone thing, could it be that it simply won't work on iPhone ? Or do I have some css/html typos ?

    Read the article

  • ASIHTTP: multi threads and multi UIPorgressView

    - by user262325
    Hello everyone I have a project to download multi files (fileurl). It display the each thread on a UITableView. In UITableView - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger row=[indexPath row]; NSInteger section=[indexPath section]; //UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"any-cell"]; static NSString *SimpleTableIdentifier1 = @"SimpleTableIdentifier1"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier1]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: SimpleTableIdentifier1] autorelease]; } UIProgressView *aUIProgressView; aUIProgressView =[[UIProgressView alloc] initWithFrame:CGRectMake( 10.9f,48.0f,300.0f,28.0f)]; [aUIProgressView setTag:row]; [aUIProgressView setProgress:0]; [cell addSubview:aUIProgressView]; [self startADownloadThread : [[downloadArray objectAtIndex:row] getURL] progressview:switchView ]; [aUIProgressView release]; [cell setText: [[downloadArray objectAtIndex:row] getURL]]; return cell; } It calls 'startADownloadThread' - (IBAction)startADownloadThread:(NSString *)fileurl progressview:(UIProgressView *)a { [a setProgress:0]; NSLog(@"Value: %f", [a progress]); [networkQueue cancelAllOperations]; [networkQueue setDownloadProgressDelegate:a]; [networkQueue setDelegate:self]; [networkQueue setRequestDidFinishSelector:@selector(requestDone:)]; [networkQueue setShowAccurateProgress:true]; NSURL *url = [NSURL URLWithString:fileurl]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [networkQueue addOperation:request]; [networkQueue go]; } I hope each aUIProgressView display the download progress of each download thread. The above source codes : Display the aUIProgressView list correctly, but only the last aUIProgressView link to a thread display the correct progress, others' value are 0 Welcome any comment Thanks interdev

    Read the article

  • iPhone SDK - (void)viewDidLoad { } - Show Progress

    - by Hank Brekke
    I have a long - (void)viewDidLoad { } function that uses the internet to load a page, and whenever the application loads the URL, the screen is black. I have a UIActivityIndicator setup to show that the address is loading, but I don't know how to prevent it from seeming as if the application is not responding, and I don't want to show the network activity indicator [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; because the screen will still be black, just with a loader in the top corner. My code is below: - (void)viewDidLoad { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; email.text = [defaults objectForKey:@"mom_email"]; pass.text = [defaults objectForKey:@"mom_pass"]; if (email.text != nil && pass.text != nil) { [self login:loginBtn]; } } - (IBAction)login:(id)sender { [email resignFirstResponder]; [pass resignFirstResponder]; [loader startAnimating]; // Does nothing though NSString *em = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)email.text,NULL,(CFStringRef)@"!*'();:@&=+$,/?%#[]",kCFStringEncodingUTF8); NSString *ps = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)pass.text,NULL,(CFStringRef)@"!*'();:@&=+$,/?%#[]",kCFStringEncodingUTF8); NSURL *url = [[NSURL alloc] initWithScheme:@"http" host:@"localhost" path:[[NSString alloc] initWithFormat:@"/app/login.php?email=%@&pass=%@", em, ps]]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *loginResult = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; [loader stopAnimating]; NSRange range = [loginResult rangeOfString:@"1"]; if (range.location != NSNotFound) { [self dismissModalViewControllerAnimated:YES]; // Doesn't do anything if function called from viewDidLoad } }

    Read the article

  • why AVAudioplayer doesn't stop/pause when viewWillDisappear?

    - by Rahul Vyas
    I am using avaudioplayer in my app. on viewwilldisappear i want to pause/stop the sound and on viewwill appear i want to play sound again.how do i do this? i'm using this code on viewWillAppear:- if(self.TickPlayer) { [self.TickPlayer play]; } if(self.TickPlayer.volume<0) { self.TickPlayer.volume=1.0; } and this on viewWillDisAppear if(self.TickPlayer) { [self.TickPlayer stop]; } here is the method which plays the sound -(void)PlayTickTickSound:(NSString*)SoundFileName { //Get the filename of the sound file: NSString *path = [NSString stringWithFormat:@"%@%@",[[NSBundle mainBundle] resourcePath],[NSString stringWithFormat:@"/%@",SoundFileName]]; //Get a URL for the sound file NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO]; NSError *error; if(self.TickPlayer==nil) { self.TickPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:filePath error:&error]; // handle errors here. self.TickPlayer.delegate=self; [self.TickPlayer setNumberOfLoops:-1]; // repeat forever [self.TickPlayer play]; } if(self.TickPlayer) { [self.TickPlayer play]; } } and i'm calling it in method which fires every second using a timer in viewDidLoad- self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateCountdown) userInfo:nil repeats:YES]; -(void) updateCountdown { [self PlayTickTickSound:@"tick.caf"]; } i'm also playing a beep sound using avaudioplayer at a specific condition when alert appears.that works fine but this is not working as expected

    Read the article

  • UIWebView not loading URL

    - by jerincbus
    I'm having trouble getting a UIWebView to load a URL that I'm sending to it. Before I get into my code I was wondering if URL has to start with "http://" or can it start with "www."? I'm using an IBAction to push a UIView on to the stack: (IBAction)goToWebView { WebViewController *webController = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]]; //set the strings webController.webTitle = [self Title]; webController.webURL = [self website]; //Push the new view on the stack [[self navigationController] pushViewController:webController animated:YES]; [webController release]; webController = nil; } Then here is my WebViewController.h file: @interface WebViewController : UIViewController { IBOutlet UIWebView *webView; NSString *webTitle; NSString *webURL; } @property (nonatomic, retain) IBOutlet UIWebView *webView; @property (nonatomic, retain) NSString *webTitle; @property (nonatomic, retain) NSString *webURL; here And my WebViewController.m file: - (void)viewDidLoad { [super viewDidLoad]; NSString *urlAddress = webURL; //Create a URL object. NSURL *url = [NSURL URLWithString:urlAddress]; //URL Requst Object NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; //Load the request in the UIWebView. [webView loadRequest:requestObj]; }

    Read the article

  • Using NSURLRequest to pass key-value pairs to PHP script with POST

    - by Ralf Mclaren
    Hi, I'm fairly new to objective-c, and am looking to pass a number of key-value pairs to a PHP script using POST. I'm using the following code but the data just doesn't seem to be getting posted through. I tried sending stuff through using NSData as well, but neither seem to be working. NSDictionary* data = [NSDictionary dictionaryWithObjectsAndKeys: @"bob", @"sender", @"aaron", @"rcpt", @"hi there", @"message", nil]; NSURL *url = [NSURL URLWithString:@"http://myserver.com/script.php"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:[NSData dataWithBytes:data length:[data count]]]; NSURLResponse *response; NSError *err; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err]; NSLog(@"responseData: %@", content); This is getting sent to this simple script to perform a db insert: <?php $sender = $_POST['sender']; $rcpt = $_POST['rcpt']; $message = $_POST['message']; //script variables include ("vars.php"); $con = mysql_connect($host, $user, $pass); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); mysql_query("INSERT INTO php_test (SENDER, RCPT, MESSAGE) VALUES ($sender, $rcpt, $message)"); echo "complete" ?> Any ideas?

    Read the article

  • Drawing a PDF Right-Side-Up in CGContext

    - by Carter Allen
    I'm overriding the drawRect: method in a custom UIView, and I'm doing some custom drawing. All was going well, until I needed to draw a PDF resource (a vector glyph, to be precise) into the context. First I retrieve the PDF from a file: NSURL *pdfURL = [NSURL fileURLWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"CardKit.bundle/A.pdf"]]; CGPDFDocumentRef pdfDoc = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfDoc, 1); Then I create a box with the same dimensions as the loaded PDF: CGRect box = CGPDFPageGetBoxRect(pdfPage, kCGPDFArtBox); Then I save my graphics state, so that I don't screw anything up: CGContextSaveGState(context); And then I perform a scale+translate of the CTM, theoretically flipping the whole context: CGContextScaleCTM(context, 1.0, -1.0); CGContextTranslateCTM(context, 0.0, rect.size.height); I then scale the PDF so that it fits into the view properly: CGContextScaleCTM(context, rect.size.width/box.size.width, rect.size.height/box.size.height); And finally, I draw the PDF and restore the graphics state: CGContextDrawPDFPage(context, pdfPage); CGContextRestoreGState(context); The issue is that there is nothing visible drawn. All this code should theoretically draw the PDF glyph into the view, right? If I remove the scale+translate used to flip the context, it draws perfectly: it just draws upside-down. Any ideas?

    Read the article

  • Can AVAudioSession do full duplex?

    - by Eric Christensen
    It would seem like it should be able to, but the following breakout test code can't do both: //play a file: NSArray *pathsArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [pathsArray objectAtIndex:0]; NSString* playFilePath=[documentsDirectory stringByAppendingPathComponent:@"testplayfile.wav"]; AVAudioPlayer *tempplayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:playFilePath] error:nil]; [tempplayer prepareToPlay]; [tempplayer play]; //and record a file: NSString* recFilePath=[documentsDirectory stringByAppendingPathComponent:@"testrecordfile.wav"]; AVAudioRecording *soundrecording = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:recFilePath] settings:nil error:nil]; [soundrecording prepareToRecord]; [soundrecording record]; This is the minimum I can think of to individually play one file and record another. And this works just fine in the simulator. I can play back a file and record at the same time. But it doesn't work on the iphone itself. If I comment out either function, the other performs fine. The playback plays fine either alone or with both, if it's first. If I comment out the playback, the record records fine. (There's additional code to stop the recording not shown here.) So each works fine, but not together. I know audioQueue has a setting to allow both, but I don't see an analogue for AVAudioSessions. Any idea if it's possible, and if so, what I need to add? Thanks!

    Read the article

  • EXC_BAD_ACCESS NSUrlConnection

    - by Lars
    Hi all, i got an EXC_BAD_ACCESS when i perform the last line of the function (webData). -(void)requestSoap{ NSString *requestUrl = @"http://www.website.com/webservice.php"; NSString *soapMessage = @"the soap message"; //website and soapmessage are valid in original code. NSError **error; NSURLResponse *response; //Convert parameter string to url NSURL *url = [NSURL URLWithString:requestUrl]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; //Create an XML message for webservice [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; NSData *webData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:error]; } I tried not to release a thing, because what i read on the net is it's almost always a memory thing. When i debug the code (NSZombieEnabled = YES) this is what i get: [Session started at 2010-05-31 15:56:13 +0200.] GNU gdb 6.3.50-20050815 (Apple version gdb-1461.2) (Fri Mar 5 04:43:10 UTC 2010) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all Attaching to process 19856. test(19856) malloc: recording malloc stacks to disk using standard recorder test(19856) malloc: enabling scribbling to detect mods to free blocks test(19856) malloc: process 19832 no longer exists, stack logs deleted from /tmp/stack-logs.19832.test.w9Ek4L.index test(19856) malloc: stack logs being written into /tmp/stack-logs.19856.test.URRpQF.index Program received signal: “EXC_BAD_ACCESS”. Does anybody have a clue?? Thanks a lot! Lars

    Read the article

  • Integrating twitpic OAuth for iPhone.

    - by asadqamber
    How can I integrate twitpic API with OAuth for posting an image from iPhone? Any help or tutorial? Currently I am doing... NSURL *twitpicURL = [NSURL URLWithString:@"http://api.twitpic.com/2/upload.format"]; theRequest = [NSMutableURLRequest requestWithURL:twitpicURL]; [theRequest setHTTPMethod:@"POST"]; // Set the params NSString *message = theMessage; [theRequest addValue:@"http://api.twitter.com/" forHTTPHeaderField:@"OAuth realm"]; [theRequest addValue:TWITPIC_API_KEY forHTTPHeaderField:@"oauth_consumer_key"]; [theRequest addValue:@"HMAC-SHA1" forHTTPHeaderField:@"oauth_signature_method"]; [theRequest addValue:USER_OAUTH_TOKEN forHTTPHeaderField:@"oauth_token"]; [theRequest addValue:USER_OAUTH_SECRET forHTTPHeaderField:@"oauth_secret"]; [theRequest addValue: @"1272325550" forHTTPHeaderField:@"oauth_timestamp"]; [theRequest addValue:nil forHTTPHeaderField:@"oauth_nonce"]; [theRequest addValue:@"1.0" forHTTPHeaderField:@"oauth_version"]; [theRequest addValue:nil forHTTPHeaderField:@"oauth_signature"]; NSMutableData *postBody = [NSMutableData data]; [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"source\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"lighttable"] dataUsingEncoding:NSUTF8StringEncoding]]; // Message [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"message\"\r\n\r\n%@", message]dataUsingEncoding:NSUTF8StringEncoding]]; // Media [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"media\"; filename=\"%@\"\r\n", @"doc_twitpic_image.jpg"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"Content-Type: image/jpg\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; // data as JPEG [postBody appendData:[[NSString stringWithFormat:@"Content-Transfer-Encoding: binary\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[NSData dataWithData:image]]; [theRequest setHTTPBody:postBody]; [theRequest setValue:[NSString stringWithFormat:@"%d", [postBody length]] forHTTPHeaderField:@"Content-Length"]; theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

    Read the article

  • Problems playing multiple sounds using AVPlayer (NOT AVAudioPlayer)

    - by myetter37
    I'm trying to play a background song in my iPhone game and also have sound effects, using the AVFoundation framework and AVPlayerItem. I've scoured the Internet for help with AVPlayerItem and AVPlayer but I'm only finding stuff about AVAudioPlayer. The background song plays fine, but when the character jumps, I have 2 problems: 1) On the initial jump ([player play] inside jump method), the jump sound effect interrupts the background music. 2) If I try to jump again, the game crashes with the error "AVPlayerItem cannot be associated with more than one instance of AVPlayer" My professor told me to create a new instance of AVPlayer for each sound I want to play, so I'm confused. I'm doing data driven design, so my sound files are listed in a .txt and then loaded into a NSDictionary. Here's my code: - (void) storeSoundNamed:(NSString *) soundName withFileName:(NSString *) soundFileName { NSURL *assetURL = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:soundName ofType:soundFileName]]; AVURLAsset *mAsset = [[AVURLAsset alloc] initWithURL:assetURL options:nil]; AVPlayerItem *mPlayerItem = [AVPlayerItem playerItemWithAsset:mAsset]; [soundDictionary setObject:mPlayerItem forKey:soundName]; NSLog(@"Sound added."); } - (void) playSound:(NSString *) soundName { // from .h: @property AVPlayer *mPlayer; // from .m: @synthesize mPlayer = _mPlayer; _mPlayer = [[AVPlayer alloc] initWithPlayerItem:[soundDictionary valueForKey:soundName]]; [_mPlayer play]; NSLog(@"Playing sound."); } If I move this line from the second method into the first: _mPlayer = [[AVPlayer alloc] initWithPlayerItem:[soundDictionary valueForKey:soundName]]; The game does not crash, and the background song will play perfectly, but the jump sound effect does not play, even though the console is showing "Playing sound." on each jump. Thank you

    Read the article

  • Testing background audio in the simulator

    - by Cactuar
    I'm experimenting with the new background audio service in iPhone OS 4.0 but I can't get it to work in the simulator. According to this page: iPhone Application Programming Guide: Executing Code in the Background it seems that all I have to do is add the a UIBackgroundModes key with an array containing audio to my Info.plist file and the audio my application plays should automatically continue when I switch to another app. I have done this but the audio still pauses as I switch to another app, when I switch back it continues where it left off. This is the code I'm using to play the sound: NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audio.mp3", [[NSBundle mainBundle] resourcePath]]]; NSError *error; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; audioPlayer.numberOfLoops = -1; if (audioPlayer == nil) NSLog(@"%@", [error userInfo]); else [audioPlayer play]; Has anyone gotten this to work? Could it be that it would work on an actual device and it's just a problem with the simulator? I'm a bit hesitant to install 4.0 on my phone since I've heard it's still very buggy. Wish I had another device to use only for development.

    Read the article

  • iphone webview dynamic font support

    - by Kiran
    Friends, I am trying to build a simple iphone application to view a local webpage that uses dynamic fonts. The url is www.eenadu.net. I have just a single view based application and inserted a webview into the view and implementing the webviewdelegate in viewcontroller. The site uses ttf/eot fonts that are dynamically downloadable by browser from http://www.eenadu.net/eenadu.ttf or http://www.eenadu.net/EENADU0.eot. Here is what I am doing in the code by doing some research: Code: ( void ) loadFont { NSString *fontPath = [[NSBundle mainBundle] pathForResource:@"eenadu" ofType:@"ttf"]; CGDataProviderRef fontDataProvider = CGDataProviderCreateWithFilename([fontPath UTF8String]); // Create the font with the data provider, then release the data provider. customFont = CGFontCreateWithDataProvider(fontDataProvider); CGDataProviderRelease(fontDataProvider); fontPath = [[NSBundle mainBundle] pathForResource:@"eenadu" ofType:@"eot"]; fontDataProvider = CGDataProviderCreateWithFilename([fontPath UTF8String]); // Create the font with the data provider, then release the data provider. customFont = CGFontCreateWithDataProvider(fontDataProvider); CGDataProviderRelease(fontDataProvider); } (void) viewDidLoad { [super viewDidLoad]; [self loadFont]; [webView setBackgroundColor:[UIColor whiteColor]]; NSString *urlAddress = @"http://www.eenadu.net/"; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; } I see that the page loads however doesn't display the font. Please help. Also, For loadFont, I have included the fonts in the build with right names and took care of the case as well.

    Read the article

  • Google Reader API with Objective-C - Problem getting token

    - by JustinXXVII
    I am able to successfully get the SID (SessionID) for my Google Reader account. In order to obtain the feed and do other operations inside Google Reader, you have to obtain an authorization token. I'm having trouble doing this. Can someone shed some light? //Create a cookie to append to the GET request NSDictionary *cookieDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"SID",@"NSHTTPCookieName",self.sessionID,@"NSHTTPCookieValue",@".google.com",@"NSHTTPCookieDomain",@"/",@"NSHTTPCookiePath",@"NSHTTPCookieExpires",@"160000000000",nil]; NSHTTPCookie *authCookie = [NSHTTPCookie cookieWithProperties:cookieDictionary]; //The URL to obtain the Token from NSURL *tokenURL = [NSURL URLWithString:@"http://www.google.com/reader/api/0/token"]; NSMutableURLRequest *tokenRequest = [NSMutableURLRequest requestWithURL:tokenURL]; //Not sure if this is right: add cookie to array, extract the headers from the cookie inside the array...? [tokenRequest setAllHTTPHeaderFields:[NSHTTPCookie requestHeaderFieldsWithCookies:[NSArray arrayWithObjects:authCookie,nil]]]; //This gives me an Error 403 Forbidden in the didReceiveResponse of the delegate [NSURLConnection connectionWithRequest:tokenRequest delegate:self]; I get a 403 Forbidden error as the response from Google. I'm probably not doing it right. I set the dictionary values according to the documentation for NSHTTPCookie.

    Read the article

  • ASIHTTPRequest - HTTPS

    - by Tejaswi Yerukalapudi
    Does ASIHTTPRequest support HTTPS connections? My connection right now works for a HTTP connection and errors if I try a HTTPS Connection. (Goes into requestFailed and gives me a ASIHTTPErrorRequestDomain) -(void) getPatientsList { av.hidden = NO; [av startAnimating]; NSString *urlString = [IP stringByAppendingString:@"Method1"]; NSURL *url = [NSURL URLWithString:urlString]; ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; NSLog(@"URL = %@",url); [request setRequestMethod:@"POST"]; [request setPostValue:@"val1" forKey:@"key1"]; [request setPostValue:@"val2" forKey:@"key2"]; [request setDelegate:self]; [request startAsynchronous]; } - (void)requestFinished:(ASIHTTPRequest *)request { // Use when fetching text data //NSString *responseString = [request responseString]; // Use when fetching binary data NSData *responseData = [request responseData]; [self parsePatients:responseData]; [av stopAnimating]; av.hidden = YES; } - (void)requestFailed:(ASIHTTPRequest *)request { NSError *error = [request error]; [av stopAnimating]; av.hidden = YES; } Thanks, Teja

    Read the article

  • Play multiple audio files using AVAudioPlayer

    - by inScript09
    Hi all, I am planning on releasing 10 of my song recordings for free but bundled in an iphone app. They are not available on web or itunes or anywhere as of now. I am new to iphone sdk (latest) as you can imagine, so I have been going through the developer documentation, various forums and stackoverflow to learn. Apple's avTouch sample application was a great start. But I want my app to play all the 10 tracks one by one. All the songs are added to resources folder and are named as track1, track2...track10. In the avTouch app code I can see the following 2 parts which is where I think I need to make changes to achieve what I am looking for. But I am lost. // Load the array with the sample file NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"m4a"]]; - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag { if (flag == NO) NSLog(@"Playback finished unsuccessfully"); [player setCurrentTime:0.]; [self updateViewForPlayerState]; } can anyone please help me on 1. how to load the array with all the 10 tracks which are added to resources folder 2. and when I hit play, player should start the first track. when the 1st track ends 2nd track should start and so on for the remaining tracks. Thank You

    Read the article

  • NSString's stringByAppendingPathComponent: removes a '/' in http://

    - by Jasarien
    I've been modifying some code to work between Mac OS X and iPhone OS. I came across some code that was using NSURL's URLByAppendingPathComponent: (added in 10.6), which as some may know, isn't available in the iPhone SDK. My solution to make this code work between OS's is to use NSString *urlString = [myURL absoluteString]; urlString = [urlString stringByAppendingPathComponent:@"helloworld"]; myURL = [NSURL urlWithString:urlString]; The problem with this is that NSString's stringByAppendingPathComponent: seems to remove one of the /'s from the http:// part of the URL. Is this intended behaviour or a bug? Edit Ok, So I was a bit too quick in asking the question above. I re-read the documentation and it does say: Note that this method only works with file paths (not, for example, string representations of URLs) However, it doesn't give any pointers in the right direction for what to do if you need to append a path component to a URL on the iPhone... I could always just do it manually, adding a /if necessary and the extra string, but I was looking to keep it as close to the original Mac OS X code as possible...

    Read the article

  • Printing Pdf using AirPrint causes cut-off content

    - by Jatin Patel
    Here i am printing pdf with size 'pageSize = CGSizeMake(640, 832);'. this size is larget then A4 size page aspected. so i will cut-off some text(means it will not print whole page). while printing same pdf using MAC, it will print whole page with help of option (scale to fit). so can any one help me to come out from this problem.. is there any option in IOS sdk for scale to fit. here is my code.. -(void)printItem { NSArray *aArrPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) ; NSString *aStr = [[aArrPaths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"PropertyReport_%d.pdf",self.propertyId]]; // NSString *aStr = [[NSBundle mainBundle] pathForResource:@"TRADUZIONE HELP SECTIONS REV2" ofType:@"pdf"]; NSURL *url=[[NSURL alloc] initFileURLWithPath:aStr]; NSData *data=[[NSData alloc] initWithContentsOfURL:url]; printController = [UIPrintInteractionController sharedPrintController]; if(printController && [UIPrintInteractionController canPrintData:data]) { printController.delegate = self; UIPrintInfo *printInfo = [UIPrintInfo printInfo]; printInfo.outputType = UIPrintInfoOutputGeneral; //printInfo.jobName = [NSString stringWithFormat:@"New Image"]; printInfo.duplex = UIPrintInfoDuplexLongEdge; printController.printInfo = printInfo; printController.showsPageRange = YES; printController.printingItem = data; void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) { if (!completed && error) { //NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code); } }; // aWebViewPDF.hidden=FALSE; [printController presentAnimated:YES completionHandler:completionHandler]; } } Thanks Jatin Patel

    Read the article

  • iPhone SDK: How do you download video files to the Document Directory and then play them?

    - by Jessica
    I've been fooling around with code for ages on this one, I would be very grateful if someone could provide a code sample that downloaded this file from a server http://www.archive.org/download/june_high/june_high_512kb.mp4, (By the way it's not actually this file, it's just a perfect example for anyone trying to help me) and then play it from the documents directory. I know it seems lazy of me to ask this but I have tried so many different variations of NSURLConnection that it's driving me crazy. Also, if I did manage to get the video file downloaded would I be correct in assuming this code would then successfully play it: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"june_high_512kb.mp4"]; NSURL *movieURL = [NSURL fileURLWithPath:path]; self.theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; [_theMovie play]; If the above code would work in playing a video file from the document directory, then I guess the only thing I would need to know is, how to download a video file from a server. Which is what seems to be my major problem. Any help is greatly appreciated.

    Read the article

  • iphone-AVAudio Player Crashes

    - by user2779450
    I have an app that uses an avaudio player for two things. One of them is to play an explosion sound when a uiimageview collision is detected, and the other is to play a lazer sound when a button is pressed. I declared the audioplayer in the .h class, and I call it each time the button is clicked by doing this: NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"/lazer" ofType:@"mp3"]]; NSError *error; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; if (error) { NSLog(@"Error in audioPlayer: %@", [error localizedDescription]); } else { [audioPlayer prepareToPlay]; } [audioPlayer play]; This works fine, but after many uses of the game, the audio will stop play when i hit the button, and when a collision is detected, the game crashes. Here is my crash log: 2013-09-18 18:09:19.618 BattleShip[506:907] 18:09:19.617 shm_open failed: "AppleAudioQueue.41.2619" (23) flags=0x2 errno=24 (lldb) Suggestions? Could there be something to do with repeatedly creating an audio player? Alternatives maybe?

    Read the article

  • Troubleshooting FORM POST problems

    - by brettr
    I'm using the following code to submit to a WCF service. I keep getting an error that the key is invalid. I have a webpage on the same server that I submit the same data (but different key) using a FORM POST. It works fine that way. I put the URL below all in a URL (including valid key from server webpage) and get the key is invalid error. I'm thinking the data I'm submitting through the iPhone isn't really going across as a FORM POST but rather as a URL. Is there anything I may be doing wrong in the following code or any other suggestions? NSString *stringForURL = @"https://abc.com/someservice.aspx"; NSURL *URL=[[NSURL alloc] initWithString:stringForURL]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL]; NSString *request_body = [NSString stringWithFormat:@"prop1=value1&key=%@", [@"r2xHEuzgDTQEWA5Xe6+k9BSVrgsMX2mWQBW/39nqT4s=" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSData *postData = [request_body dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:postData]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [NSThread sleepForTimeInterval:1]; self.receivedData = [[NSMutableData data] retain];

    Read the article

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