Search Results

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

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

  • Send parameters to a web service.

    - by Alejandra Meraz
    Before I start: I'm programming for Iphone, using objective C. I have already implemented a call to a web service function using NSURLRequest and NSURLConnection. The function then returns a XML with the info I need. The code is as follows: NSURL *url = [NSURL URLWithString:@"http://myWebService/function"]; NSMutableURLRequest theRequest = [[NSMutableURLRequest alloc] initWithURL:url]; NSURLConnection theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; i also implemented the methods didRecieveResponse didRecieveAuthenticationChallenge didRecievedData didFailWithError connectionDidFinishLoading. And it works perfectly. Now I need to send 2 parameters to the function: "location" and "module". I tried using the following modification: NSMutableURLRequest theRequest = [[NSMutableURLRequest alloc] initWithURL:url]; [theRequest setValue:@"USA" forHTTPHeaderField:@"location"]; [theRequest setValue:@"DEVELOPMENT" forHTTPHeaderField:@"module"]; NSURLConnection theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; But it doesn't seem to work. I'm doing something wrong? is there a way to know if I'm using the wrong names for the parameters (as maybe it is "Location" or "LOCATION" or it doesn't matter?)? or a way to know which parameters is the function waiting for... Extra info: I don't have access to the source of the web service so I can't modify it. But I can access the WSDL. The person who made the function say is all there... but I can't make any sense of it .< Any help would be appreciated. :)

    Read the article

  • CoreData : store images to DB or not?

    - by Meko
    Hi.I am making an app that it takes photos from web site for some Username and shows it on UITable with username then when clicking user name it shows photos for this user and then clicking to name of photo it shows full screen photo. My question is I am using NSData to get photos from internet.Am I have to save also those data to CoreDAta? I am using like when pressing name of user it again creates NSData and downloads photos from internet and shows them on UTable. And it takes time. What is good approach? and How can save this images to CoreDAta? I am using this method NSData *imageData=[flickr dataForPhotoID:firstPhoto.id fromFarm:firstPhoto.farm onServer:firstPhoto.server withSecret:firstPhoto.secret inFormat: FlickrFetcherPhotoFormatSquare]; and here definition of dataForPtohoID method - (NSData *)dataForPhotoID:(NSString *)photoID fromFarm:(NSString *)farm onServer:(NSString *)server withSecret:(NSString *)secret inFormat:(FlickrFetcherPhotoFormat)format { #if TEST_HIGH_NETWORK_LATENCY sleep(1); #endif NSString *formatString; switch (format) { case FlickrFetcherPhotoFormatSquare: formatString = @"s"; break; case FlickrFetcherPhotoFormatLarge: formatString = @"b"; break; } NSString *photoURLString = [NSString stringWithFormat:@"http://farm%@.static.flickr.com/%@/%@_%@_%@.jpg", farm, server, photoID, secret, formatString]; NSURL *url = [NSURL URLWithString:photoURLString]; return [NSData dataWithContentsOfURL:url]; }

    Read the article

  • Problem with reusing UITableViewCell's

    - by Sheehan Alam
    I have a UITableView that is re-using cells when the user scrolls. Everything appears and scrolls fine, except when the user clicks on an actual row, the highlighted cell displays some text from another cell. I'm not exactly sure why. #define IMAGE_TAG 1111 #define LOGIN_TAG 2222 #define FULL_NAME_TAG 3333 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; STUser *mySTUser = [[[STUser alloc]init]autorelease]; mySTUser = [items objectAtIndex:indexPath.row]; AsyncImageView* asyncImage = nil; UILabel* loginLabel = nil; UILabel* fullNameLabel = nil; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; } else { asyncImage = (AsyncImageView *) [cell.contentView viewWithTag:IMAGE_TAG]; loginLabel = (UILabel *) [cell.contentView viewWithTag:LOGIN_TAG]; fullNameLabel = (UILabel *) [cell.contentView viewWithTag:FULL_NAME_TAG]; } // Configure the cell... cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; CGRect frame = CGRectMake(0, 0, 44, 44); asyncImage = [[[AsyncImageView alloc]initWithFrame:frame] autorelease]; asyncImage.tag = IMAGE_TAG; NSURL* url = [NSURL URLWithString:mySTUser.avatar_url_large]; [asyncImage loadImageFromURL:url]; [cell.contentView addSubview:asyncImage]; loginLabel.tag = LOGIN_TAG; CGRect loginLabelFrame = CGRectMake(60, 0, 200, 10); loginLabel = [[[UILabel alloc] initWithFrame:loginLabelFrame] autorelease]; loginLabel.text = [NSString stringWithFormat:@"%@",mySTUser.login]; [cell.contentView addSubview:loginLabel]; fullNameLabel.tag = FULL_NAME_TAG; CGRect fullNameLabelFrame = CGRectMake(60, 20, 200, 10); fullNameLabel = [[[UILabel alloc] initWithFrame:fullNameLabelFrame] autorelease]; fullNameLabel.text = [NSString stringWithFormat:@"%@ %@",mySTUser.first_name, mySTUser.last_name]; //[NSString stringWithFormat:@"%@",mySTUser.login]; [cell.contentView addSubview:fullNameLabel]; return cell; }

    Read the article

  • MPMoviePlayerController problem at start

    - by Infinity
    Hello guys! I have a problem with MPMoviePlayerController, because when I start it in fullscreen it exists, but the song is still playing. I added the MPMoviePlayerDidExitFullscreenNotification notification and it says that when the video starts playin it exists the full screen. Here's my code: _multimediaPlayer = [[MPMoviePlayerController alloc] init]; _multimediaPlayer.controlStyle = MPMovieControlStyleDefault; _multimediaPlayer.initialPlaybackTime = 0; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayerDidExitFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayerPlaybackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil]; NSString *path = [NSString stringWithFormat:@"%@/mag_%d/%@", [FMUtils documentsFolderPathWithFile:nil], _magID, _pageObject.fileName]; if ([FMUtils fileExistsAtPath:path]) { _multimediaPlayer.contentURL = [NSURL fileURLWithPath:path]; } else { _multimediaPlayer.contentURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", self.dataURL, _pageObject.fileName]]; } CGSize objectViewSize = self.frame.size; _multimediaPlayer.view.frame = CGRectMake(0, 0, objectViewSize.width, objectViewSize.height); [self addSubview:_multimediaPlayer.view]; if (_pageObject.blink) { [_multimediaPlayer setFullscreen:YES animated:YES]; } [_multimediaPlayer play]; Most of the time it happens when the video is not downloaded and it needs to stream it. Do you have any idea why is this happen?

    Read the article

  • Pass Result of ASIHTTPRequest "requestFinished" Back to Originating Method

    - by Intelekshual
    I have a method (getAllTeams:) that initiates an HTTP request using the ASIHTTPRequest library. NSURL *httpURL = [[[NSURL alloc] initWithString:@"/api/teams" relativeToURL:webServiceURL] autorelease]; ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:httpURL] autorelease]; [request setDelegate:self]; [request startAsynchronous]; What I'd like to be able to do is call [WebService getAllTeams] and have it return the results in an NSArray. At the moment, getAllTeams doesn't return anything because the HTTP response is evaluated in the requestFinished: method. Ideally I'd want to be able to call [WebService getAllTeams], wait for the response, and dump it into an NSArray. I don't want to create properties because this is disposable class (meaning it doesn't store any values, just retrieves values), and multiple methods are going to be using the same requestFinished (all of them returning an array). I've read up a bit on delegates, and NSNotifications, but I'm not sure if either of them are the best approach. I found this snippet about implementing callbacks by passing a selector as a parameter, but it didn't pan out (since requestFinished fires independently). Any suggestions? I'd appreciate even just to be pointed in the right direction. NSArray *teams = [[WebService alloc] getAllTeams]; (currently doesn't work, because getAllTeams doesn't return anything, but requestFinished does. I want to get the result of requestFinished and pass it back to getAllTeams:)

    Read the article

  • Resize view on iPhone when rotating

    - by BCBomb47
    I have an application with many views. I want only a couple of the views to be able to rotate to landscape when the device is rotated. I found out that I couldn't use (BOOL)shouldAutorotateToInterfaceOrientation because that would rotate every view in my app. I found a solution to this problem here on Stack Overflow but now I have another issue to deal with. The view rotates when I turn the device but it still shows the view as if it were still in portrait mode (straight up and down). The top and bottom of the view is cut off. Is there a way to have the view rotate and also adjust its size to fit the new orientation? I also found this but wasn't able to get it to work. Here's my code for that view: @implementation businessBank @synthesize webView, activityIndicator; - (void)viewDidLoad { [super viewDidLoad]; NSString *urlAddress = @"website_url"; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; } - (void)didRotate:(NSNotification *)notification { UIDeviceOrientation orientation = [[notification object] orientation]; if (orientation == UIDeviceOrientationLandscapeLeft) { [self.view setTransform:CGAffineTransformMakeRotation(M_PI / 2.0)]; } else if (orientation == UIDeviceOrientationLandscapeRight) { [self.view setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)]; } else if (orientation == UIDeviceOrientationPortraitUpsideDown) { [self.view setTransform:CGAffine TransformMakeRotation(M_PI)]; } else if (orientation == UIDeviceOrientationPortrait) { [self.view setTransform:CGAffineTransformMakeRotation(0.0)]; } }

    Read the article

  • Google Translate API for iPhone - UTF8 problem in Chinese Translation

    - by Sky Chen
    I've tested a workable translation API url by: http://translate.google.com/translate_a/t?client=t&text=%E5%BB%A3%E5%A0%B4&langpair=zh|zh-CN And it returns the correct result as the following which is in JSON format: {"sentences":[{"trans":"??","orig":"??","translit":"Guangchang"}],"src":"zh-CN"} However, when I try to use this function in XCode, I experienced this problem ... Here is my code: NSData *data; NSString *urlPath = [NSString stringWithFormat:@"/translate_a/t?client=t&text=%@&langpair=zh|zh-CN",qText]; NSURL *url = [[NSURL alloc] initWithScheme:@"http" host:@"translate.google.com" path:urlPath]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:url]; [request setHTTPMethod:@"GET"]; NSURLResponse *response; NSError *error; data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; //Problem's here. It returns nil. NSLog(result); Initially I guessed it's encoding problem so I tried other encoding as well (NSISOLatin1StringEncoding) , but I got wrong answer: {"sentences":[{"trans":"ã ","orig":"ã ","translit":"Tu¨¯ "}],"src":"zh-CN"} Does anyone know how to solve this problem? Thank you very much!

    Read the article

  • Core data migration failing with "Can't find model for source store" but managedObjectModel for source is present

    - by Ira Cooke
    I have a cocoa application using core-data, which is now at the 4th version of its managed object model. My managed object model contains abstract entities but so far I have managed to get migration working by creating appropriate mapping models and creating my persistent store using addPersistentStoreWithType:configuration:options:error and with the NSMigratePersistentStoresAutomaticallyOption set to YES. NSDictionary *optionsDictionary = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption]; NSURL *url = [NSURL fileURLWithPath: [applicationSupportFolder stringByAppendingPathComponent: @"MyApp.xml"]]; NSError *error=nil; [theCoordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:optionsDictionary error:&error] This works fine when I migrate from model version 3 to 4, which is a migration that involves adding attributes to several entities. Now when I try to add a new model version (version 5), the call to addPersistentStoreWithType returns nil and the error remains empty. The migration from 4 to 5 involves adding a single attribute. I am struggling to debug the problem and have checked all the following; The source database is in fact at version 4 and the persistentStoreCoordinator's managed object model is at version 5. The 4-5 mapping model as well as managed object models for versions 4 and 5 are present in the resources folder of my built application. I've tried various model upgrade paths. Strangely I find that upgrading from an early version 3 - 5 works .. but upgrading from 4 - 5 fails. I've tried adding a custom entity migration policy for migration of the entity whose attributes are changing ... in this case I overrode the method beginEntityMapping:manager:error: . Interestingly this method does get called when migration works (ie when I migrate from 3 to 4, or from 3 to 5 ), but it does not get called in the case that fails ( 4 to 5 ). I'm pretty much at a loss as to where to proceed. Any ideas to help debug this problem would be much appreciated.

    Read the article

  • Connection

    - by pepersview
    Hello, I would like to ask you about NSURLConnection in objective-c for iPhone. I have one app that needs to connect to one webservice to receive data (about YouTube videos), Then I have all the things that I need to connect (Similar to Hello_Soap sample code in the web). But now, my problem is that I create a class (inherits from NSObject) named Connection and I have implemented the methods: didReceiveResponse, didReceiveData, didFailWithError and connectionDidFinishLoading. Also the method: -(void)Connect:(NSString *) soapMessage{ NSLog(soapMessage); NSURL *url = [NSURL URLWithString:@"http://....."]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if( theConnection ) { webData = [[NSMutableData data] retain]; } else { NSLog(@"theConnection is NULL"); } } But when from my AppDelegate I create one Connection object: Connection * connect = [[Connection alloc] Init:num]; //It's only one param to test. [connect Connect:method.soapMessage]; And I call this method, when this finishes, it doesn't continue calling didReceiveResponse, didReceiveData, didFailWithError or connectionDidFinishLoading. I'm trying to do this but I can't for the moment. The thing I would like to do is to be able to call this class "Connection" each time that I want to receive data (after that to be parsed and displayed in UITableViews). Thank you.

    Read the article

  • Initial text and paperclipped-URL for action in UIActivityViewController & UIActivityItemSource?

    - by Benjamin Kreeger
    Finally been making it through Apple's (rather dismal) documentation on the new UIActivityViewController class and the UIActivityItemSource protocol, and I'm trying to send different data sets to different actions called from the activity view. To simplify things, I'm looking at two things. A Facebook posting action, which should say "Check this out!" and also attach a URL to the post (with that cute little paperclip). A Twitter posting action, which should say "Check this out, with #hashtag!" and also attach that same URL (with the same paperclip). Here's the code I've got implemented right now. - (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType { if ([activityType isEqualToString:UIActivityTypePostToFacebook]) { return @"Check this out!"; } else if ([activityType isEqualToString:UIActivityTypePostToTwitter]) { return @"Check this out, with #hashtag!"; } return @""; } - (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController { return @""; } And then when I set up this activity view controller (it's in the same class), this is what I do. UIActivityViewController *activityView = [[UIActivityViewController alloc] initWithActivityItems:@[self] applicationActivities:nil]; [self presentViewController:activityView animated:YES completion:nil]; My dilemma is how to attach that NSURL object. It's relatively easy when calling the iOS 6 SL-class posting modals; you just call the individual methods to attach a URL or an image. How would I go about doing this here? I'll note that instead of returning NSString objects from -activityViewController:itemForActivityType, if I return just NSURL objects, they show up with that paperclip, with no body text in the post. If I return an array of those two items, nothing shows up at all.

    Read the article

  • How can I implement a volume meter for a song currently playing? (iPhone OS 3.1.3)

    - by Adam
    Hi i'm very new to core audio and I just would like some help in coding up a little volume meter for whatever's being outputted through headphones or built-in speaker. Like a dB meter. I have the following code, and have been trying to go through the apple source project "SpeakHere", but it's a nightmare trying to go through all that, without knowing how it works first... Could anyone shed some light? Here's the code I have so far... (void)displayWaveForm { while (musicIsPlaying == YES { NSLog(@"%f",sizeof(AudioQueueLevelMeterState)); } } (IBAction)playMusic { if (musicIsPlaying == NO) { NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/track7.wav",[[NSBundle mainBundle] resourcePath]]]; NSError *error; music = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; music.numberOfLoops = -1; music.volume = 0.5; [music play]; musicIsPlaying = YES; [self displayWaveForm]; } else { [music pause]; musicIsPlaying = NO; } }

    Read the article

  • UIWebview does not show up into UINavigationController

    - by Pato
    Hi I have a tabBar application. In the first tab, I have a navigation bar. In this navigation bar I have a table view. When the user clicks a cell of the table, it goes to another table view, and when the user clicks a cell in that table, it goes to a webview to open a web page. Basically, it goes fine until opening the webview. In the webview, viewDidLoad is called and seems to work properly. However, webViewDidStartLoad is never called and the web page never shows up. I am not using IB. I build the UITabBarController in the AppDelegate, where I also assign an instance of my UINavigationController for each tab. I call the webview from the second UITableViewController as follows: rssWebViewController = [[webViews objectAtIndex: indexPath.row] objectForKey:@"controller"]; [[self navigationController] pushViewController:rssWebViewController animated:YES]; I have checked that the navigationController is there and it seems just fine. The viewDidload of my webview is as follows: - (void)viewDidLoad { [super viewDidLoad]; NSString *urlAddress = self.storyUrl; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [[self rssWebView] setDelegate: self]; [[self view] addSubview:[self rssWebView]]; [rssWebView loadRequest:requestObj]; self.rssWebView.scalesPageToFit = YES; self.rssWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); } The web view controller interface is defined as follows: @interface RSSWebViewController : UIViewController <UIWebViewDelegate>{ IBOutlet UIWebView *rssWebView; IBOutlet NSString *storyUrl; IBOutlet NSString *feedName; } @property (nonatomic, retain) IBOutlet UIWebView *rssWebView; @property (nonatomic, retain) IBOutlet NSString *storyUrl; @property (nonatomic, retain) IBOutlet NSString *feedName; @end Any help is greatly appreciated.

    Read the article

  • UISplitView's DetailView not changing its content

    - by Knodel
    I have an iPad app with a UISplitView. In the Root View I have a two level UITableView (it takes its content from a plist). In the Detail View I have a UIWebView. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //Get the dictionary of the selected data source. NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row]; //Get the children of the present item. NSArray *Children = [dictionary objectForKey:@"Children"]; RootViewController *rvController = [[RootViewController alloc] init]; rvController.CurrentTitle = [dictionary objectForKey:@"Title"]; rvController.CurrentLevel = +1; //Push the new table view on the stack [self.navigationController pushViewController:rvController animated:YES]; rvController.tableDataSource = Children; NSString *name = [NSString stringWithFormat:@"%@.rtfd.zip", rvController.CurrentTitle ]; NSString* resourcePath = [[NSBundle mainBundle] resourcePath]; NSString* sourceFilePath = [resourcePath stringByAppendingPathComponent:name]; NSURL* url = [NSURL fileURLWithPath:sourceFilePath isDirectory:NO]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; [detailViewController.webView loadRequest:request]; } That's how I want the UIWebView's content to be changed. If I name the .rtfd.zip file the same as a first level cell of the UITableView, it works, UIWebView's content changes. But this doesn't work with the second level UITableView. What am I doing wrong? Thanks in advance!

    Read the article

  • UITableView Inactive Until Scroll iPhone

    - by dubbeat
    HI, I'm trying to find the cause of some annoying behaviour with my UITableView. In each cell of my table (10 of them ) I asynchronously load an image. The problem is, is that if I don't touch the app at all the imageviews will permanently show a loading icon. However as soon as I scroll a cell off the screen and back on again the image shows straight away. What could be causing this "stuck in the mud" behaviour? Is there a way to force whatever gets called when the list is scrolled to make the needed update happen? #define ASYNC_IMAGE_TAG 9999 #define LABEL_TAG 8888 // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { PromoListItem *promo = [promoList objectAtIndex:indexPath.row]; static NSString *CellIdentifier = @"Cell"; AsyncImageView *asyncImageView = nil; UILabel *label = nil; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; CGRect frame; frame.origin.x = 0; frame.origin.y = 0; frame.size.width = 100; frame.size.height = 100; asyncImageView = [[[AsyncImageView alloc] initWithFrame:frame] autorelease]; asyncImageView.tag = ASYNC_IMAGE_TAG; [cell.contentView addSubview:asyncImageView]; frame.origin.x = 110; frame.size.width =100; label = [[[UILabel alloc] initWithFrame:frame] autorelease]; label.tag = LABEL_TAG; [cell.contentView addSubview:label]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } else { asyncImageView = (AsyncImageView *) [cell.contentView viewWithTag:ASYNC_IMAGE_TAG]; label = (UILabel *) [cell.contentView viewWithTag:LABEL_TAG]; } NSURL *url = [NSURL URLWithString:promo.imgurl]; [asyncImageView loadImageFromURL:url]; label.text = promo.artistname; return cell; }

    Read the article

  • Cocoa Drag and Drop, reading back the data

    - by kodai
    Ok, I have a NSOutlineView set up, and I want it to capture PDF's if a pdf is dragged into the NSOutlineView. My first question, I have the following code: [outlineView registerForDraggedTypes:[NSArray arrayWithObjects:NSStringPboardType, NSFilenamesPboardType, nil]]; In all the apple Docs and examples I've seen I've also seen something like MySupportedType being an object registered for dragging. What does this mean? Do I change the code to be: [outlineView registerForDraggedTypes:[NSArray arrayWithObjects:@"pdf", NSStringPboardType, NSFilenamesPboardType, nil]]; Currently I have it set up to recognize drag and drop, and I can even make it spit out the URL of the dragged file once the drag is accepted, however, this leads me to my second question. I want to keep a copy of those PDF's app side. I suppose, and correct me if I'm wrong, that the best way to do this is to grab the data off the clipboard, save it in some persistant store, and that's that. (as apposed to using some sort of copy command and literally copying the file to the app director.) That being said, I'm not sure how to do that. I've the code: - (BOOL)outlineView:(NSOutlineView *)ov acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)childIndex { NSPasteboard *pboard = [info draggingPasteboard]; NSURL *fileURL; if ( [[pboard types] containsObject:NSURLPboardType] ) { fileURL = [NSURL URLFromPasteboard:pboard]; // Perform operation using the file’s URL } NSData *data = [pboard dataForType:@"NSPasteboardTypePDF"]; But this never actually gets any data. Like I said before, it does get the URL, just not the data. Does anyone have any advise on how to get this going? Thanks so much!

    Read the article

  • iPhone AVAudioPlayer failed to find codec

    - by Anthony
    Hello, I am writing an app that downloads a wav file from a server and needs to play that file. The files use the mulaw codec with 2:1 compression. These wav files are dynamically created by a seperate process so there is no way for me to preconvert the files to a different format or codec, I need to be able to play them as is. I am using an AVAudioPlayer instance initialized as follows: NSURL *audioURL = [[NSURL alloc] initWithString:@"http://xxx.../file.wav"]; NSData *audioData = [[NSData alloc] initWithContentsOfURL:audioURL]; AVAudioPlayer *audio = [[AVAudioPlayer alloc] initWithData:audioData error:nil]; [audio play]; However, when the play method executes, I get the following Console Output when executing on the Simulator: AudioQueue codec policy 1: failed to find a codec of the requested type I also tried saving the downloaded data to a local file and using a file URL, however that yeilds the same results. The downloaded file does play fine on both Mac and Windows based desktop media players. The SDK docs state that the mulaw codec is supported on the iPhone, so I am unsure why it is failing to find it. Any assistance would be greatly appreciated. Thanks.

    Read the article

  • NSString writeToFile operation couldn't be completed

    - by Chonch
    Hey, I have an xml file in my application bundle. I want to copy it to the documents folder at installation and then, every time the app launches, get the newest version of this file from the Internet. I use this code: // Check if the file exists in the documents folder NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; if (![[NSFileManager defaultManager] fileExistsAtPath:[documentsPath stringByAppendingPathComponent:@"fileName.xml"]]) // If not, copy it there (from the bundle) [[NSFileManager defaultManager] copyItemAtPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"OriginalFile.xml"] toPath:[documentsPath stringByAppendingPathComponent:@"fileName.xml"] error:nil]; // Get the newest version of the file from the server NSURL *url=[[NSURL alloc] initWithString:@"http://www.sitename.com/webservice.asmx/webserviceName"]; NSString *results = [[NSString alloc] initWithContentsOfURL:url]; // Replace the current version with the newest one, only if it is valid if (results != nil) [results writeToFile:[documentsPath stringByAppendingPathComponent:@"fileName.xml"] atomically:NO encoding:NSStringEncodingConversionAllowLossy error:nil]; The problem is that the writeToFile command always returns NO and the file's contents remain identical to the original file I included in my app bundle. I checked the value of results and it's correct. I also made sure that the app does perform the writeToString command, but still, it always returns NO. Can anybody tell me what I'm doing wrong? Thanks,

    Read the article

  • IPhone Objectvie C

    - by Sea
    I am trying to determine if a UILabel was touched and if so do something. Give .. . . . UILabel * site = [[UILabel alloc] initWithFrame:CGRectMake(0, 185, 320, 30)]; site.text = [retriever.plistDict valueForKey:@"url"]; site.textAlignment =UITextAlignmentCenter; site.backgroundColor = [UIColor clearColor]; site.textColor = [UIColor whiteColor]; site.userInteractionEnabled = YES; [theBgView addSubview:site]; [site release]; . . . Then I write the callback. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ retriever = [PListRetriever sharedInstance]; CGPoint pt = [[touches anyObject] locationInView: self]; NSURL *target = [[NSURL alloc] initWithString:[retriever.plistDict valueForKey:@"url"]]; [[UIApplication sharedApplication] openURL:target]; } The problem is right now, no matter where I touch in the View the Url is being opened. How do I determine if only just my label was touched?

    Read the article

  • Help creating custom iPhone Classes

    - by seanny94
    This should be a simple question, but I just can't seem to figure it out. I'm trying to create my own class which will provide a simpler way of playing short sounds using the AudioToolbox framework as provided by Apple. When I import these files into my project and attempt to utilize them, they just don't seem to work. I was hoping someone would shed some light on what I may be doing wrong here. simplesound.h #import <Foundation/Foundation.h> @interface simplesound : NSObject { IBOutlet UILabel *statusLabel; } @property(nonatomic, retain) UILabel *statusLabel; - (void)playSimple:(NSString *)url; @end simplesound.m #import "simplesound.h" @implementation simplesound @synthesize statusLabel; - (void)playSimple:(NSString *)url { if (url = @"vibrate") { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); statusLabel.text = @"VIBRATED!"; } else { NSString *paths = [[NSBundle mainBundle] resourcePath]; NSString *audioF1ile = [paths stringByAppendingPathComponent:url]; NSURL *audioURL = [NSURL fileURLWithPath:audioFile isDirectory:NO]; SystemSoundID mySSID; OSStatus error = AudioServicesCreateSystemSoundID ((CFURLRef)audioURL,&mySSID); AudioServicesAddSystemSoundCompletion(mySSID,NULL,NULL,simpleSoundDone,NULL); if (error) { statusLabel.text = [NSString stringWithFormat:@"Error: %d",error]; } else { AudioServicesPlaySystemSound(mySSID); } } static void simpleSoundDone (SystemSoundID mySSID, void *args) { AudioServicesDisposeSystemSoundID (mySSID); } } - (void)dealloc { [url release]; } @end Does anyone see what I'm trying to accomplish here? Does anyone know how to remedy this code that is supposedly wrong?

    Read the article

  • Querying a database using Cocoa.

    - by S1syphus
    Hello everybody. Before I start a disclaimer, I should add a little disclaimer, that I am relatively new to Cocoa development and C in general. However I do have a copy of 'Cocoa Programming for Mac OS X 3rd edition' by Aaron Hillegass, which I am working through and using as a base, if anybody has a copy I am using the 'AmaZone' example on page 346 as a template and base. I trying to develop a small client app that takes a search string then displays results from a database accordingly. The database will contain a: list of files, their location, description & creation date, so for the moment the field number and types will remain the same. After looking around on SO, I saw something like: NSURL *myURL = [NSURL URLWithString:@"http://www.myserver.com/results.php"]; NSArray *sqlResults = [[NSArray alloc] initWithContentsOfURL:myURL]; I've worked with php before, so my current thinking after seeing this is create a php script on the server that queries the database, and creates an XML output. And with the XML response, just parse it. Would this be ok? as is there any major pitfalls anybody can see, that I can't. I know there are some database bundles, I've had a look at BaseTen for Postgres, but being relatively new to this, didn't want to get in over my head. Or if anybody else has any other suggestions and ideas, they would be greatly appreciated.

    Read the article

  • http-post request for a long String in iOS

    - by onkar
    I am looking to send a very long String, which is an image that is encoded into a String. I need to send that information using POST method. I have implemented the same in Android using key-value pair, I need to implement the same in iOS using key-value pair. Please help me with useful resources/approach. EDIT 1 What have I tried [dictionnary setObject:@"admin" forKey:@"username"]; [dictionnary setObject:@"123123" forKey:@"password"]; NSError *error = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionnary options:kNilOptions error:&error]; NSString *urlString = @"MY CALL URL"; NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:jsonData]; NSURLResponse *response = NULL; NSError *requestError = NULL; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&requestError]; NSLog(@"response is obtained"); NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] ; NSLog(@"%@", responseString); EDIT 2 Error I am getting Request Error Error Domain=kCFErrorDomainCFNetwork Code=303 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 303.)" UserInfo=0x7ba0120 {NSErrorFailingURLKey=http://yahoo.com/, NSErrorFailingURLStringKey=http://yahoo.com/}

    Read the article

  • unable to get data from iphone application

    - by user317192
    Hi, I have made a php web services that takes the username and password from iPhone application and saves the data in the users table. I call that web service from my button touchup event like this: NSLog(userName.text); NSLog(password.text); NSString * dataTOB=[userName.text stringByAppendingString:password.text]; NSLog(dataTOB); NSData * postData=[dataTOB dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; NSLog(postLength); NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8888/write.php"]]; [request setURL:url]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:postData]; NSURLResponse *response; NSError *error; [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; if(error==nil) NSLog(@"Error is nil"); else NSLog(@"Error is not nil"); NSLog(@"success!"); I am getting nothing from Iphone side into the web service and I am unable to understand why this is happening. Although i debugged and found that everything is fine at the iphone application level but the call to the web service doesn't works as expected...... Please suggest..... Thanks Ashish

    Read the article

  • UIImage - should be loaded with [UIImage imageNamed:@""] or not ?

    - by sagar
    Hello ! every one. I am having number of images with in my application. ( images more than 50 - approximately & it can extend according to client's need ) Each image are very large round about - 1024 x 768 & 150 dpi Now, I have to add all this images in a scroll view & display it. Ok, My question is as follows. According to me there are two options of loading large images imageNamed:@"" load asynchronously when viewDidLoad Called. Which is more preferable ? imgModel.image=[UIImage imageNamed:[dMain valueForKey:@"imgVal"]]; or like this. NSURL *ur=[[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:lblModelName.text ofType:@"png"] isDirectory:NO]; NSURLRequest *req=[NSURLRequest requestWithURL:ur cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:40]; [ur release]; NSURLConnection *con=[[NSURLConnection alloc] initWithRequest:req delegate:self]; if(con){ myWebData=[[NSMutableData data] retain]; } else { } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [myWebData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [myWebData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [connection release]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"ImageView Ref From - %@",imgV); // my image view & set image imgV.image=[UIImage imageWithData:myWebData]; [connection release]; connection=nil; }

    Read the article

  • 401 Unauthorized returned on GET request (https) with correct credentials

    - by Johnny Grass
    I am trying to login to my web app using HttpWebRequest but I keep getting the following error: System.Net.WebException: The remote server returned an error: (401) Unauthorized. Fiddler has the following output: Result Protocol Host URL 200 HTTP CONNECT mysite.com:443 302 HTTPS mysite.com /auth 401 HTTP mysite.com /auth This is what I'm doing: // to ignore SSL certificate errors public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return true; } try { // request Uri uri = new Uri("https://mysite.com/auth"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri) as HttpWebRequest; request.Accept = "application/xml"; // authentication string user = "user"; string pwd = "secret"; string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(user + ":" + pwd)); request.Headers.Add("Authorization", auth); ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications); // response. HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // Display Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string responseFromServer = reader.ReadToEnd(); Console.WriteLine(responseFromServer); // Cleanup reader.Close(); dataStream.Close(); response.Close(); } catch (WebException webEx) { Console.Write(webEx.ToString()); } I am able to log in to the same site with no problem using ASIHTTPRequest in a Mac app like this: NSURL *login_url = [NSURL URLWithString:@"https://mysite.com/auth"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:login_url]; [request setDelegate:self]; [request setUsername:name]; [request setPassword:pwd]; [request setRequestMethod:@"GET"]; [request addRequestHeader:@"Accept" value:@"application/xml"]; [request startAsynchronous];

    Read the article

  • strange run time error message from CIImage initWithContentsOfURL

    - by Adam
    When executing the following code I receive a run time error when the code executes the second line of code. The error (which shows up in the debugger) says: [NSButton initWithContentsOfURL:]: unrecognized selector sent to instance 0x100418e10. I don't understand this message, because it looks to me (based on my source code) like the initWithContentsOfURL message is being sent to the myImage instance (of the CIImage class) ... not NSButton. Any idea what is going on? If it matters ... this code is in the Application Controller class module of an Xcode project (a Cocoa application) -- within a method that is called when I click on a button on the application window. There is only the one button on the window ... // Step1: Load the JPG file into CIImage NSURL *myURL = [NSURL fileURLWithPath:@"/Users/Adam/Documents/Images/image7.jpg"]; CIImage *myImage = [myImage initWithContentsOfURL: myURL]; if (myImage = Nil) { NSLog(@"Creating myImage failed"); return; } else { NSLog(@"Created myImage successfully"); }

    Read the article

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