Search Results

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

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

  • Pass NSURL from One Class To Another

    - by user717452
    In my appDelegate in didFinishLaunchingWithOptions, I have the following: NSURL *url = [NSURL URLWithString:@"http://www.thejenkinsinstitute.com/Journal/"]; NSString *content = [NSString stringWithContentsOfURL:url]; NSString * aString = content; NSMutableArray *substrings = [NSMutableArray new]; NSScanner *scanner = [NSScanner scannerWithString:aString]; [scanner scanUpToString:@"<p>To Download the PDF, " intoString:nil]; // Scan all characters before # while(![scanner isAtEnd]) { NSString *substring = nil; [scanner scanString:@"<p>To Download the PDF, <a href=\"" intoString:nil]; // Scan the # character if([scanner scanUpToString:@"\"" intoString:&substring]) { // If the space immediately followed the #, this will be skipped [substrings addObject:substring]; } [scanner scanUpToString:@"" intoString:nil]; // Scan all characters before next # } // do something with substrings NSString *URLstring = [substrings objectAtIndex:0]; self.theheurl = [NSURL URLWithString:URLstring]; NSLog(@"%@", theheurl); [substrings release]; The console printout for theheurl gives me a valid URL ending in .pdf. In the class I would like to load the URL, I have the following: - (void)viewWillAppear:(BOOL)animated { _appdelegate.theheurl = currentURL; NSLog(@"%@", currentURL); NSLog(@"%@", _appdelegate.theheurl); [worship loadRequest:[NSURLRequest requestWithURL:currentURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]]; timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(tick) userInfo:nil repeats:YES]; [super viewWillAppear:YES]; } However, both NSLogs in that class come back null. What am I Doing wrong in getting the NSURL from the AppDelegate to the class to load it?

    Read the article

  • Download files with NSURL

    - by Ishwar
    I am trying to download a list of files from a ftp server using: NSURL *ftpUrl = [NSURL URLWithString:@"ftp://xxx:[email protected]"]; I HAVE to use FTP, so please do not recommend an alternative. I want to know how to get the list of files from the root directory and also navigate inside folders (of FTP server). P.S: I do not think external library would be required to accomplish such an easy task, but if I must, any recommendations would be appreciated. Thank You :)

    Read the article

  • NSString to NSURL objects

    - by user337844
    Hello, I have an array that I populated with my plist file, which looks something like this: <array> <string>http://www.apple.com</string> <string>http://www.google.com</string> <string>http://www.amazon.com</string> </array> So, I'm looking to convert these NSString objects to NSURL objects when I call them in my didSelectRowAtIndexPath method. Any ideas? This is what I have right now: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger row = [indexPath row]; if (self.viewController == nil) { TemplateViewController *details = [[TemplateViewController alloc] initWithNibName:@"TemplateViewController" bundle:nil]; self.viewController = details; [details release]; } NSString *tempURLString = [tieroneurlArray objectAtIndex:row]; NSURL *loadingUrl = [NSURL URLWithString:tempURLString]; [tieroneurlArray addObject:loadingUrl]; viewController.title = [NSString stringWithFormat:@"%@", [tieroneArray objectAtIndex:row]]; [self.viewController setTableURL:[tieroneurlArray objectAtIndex:row]]; TemplateAppAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.templateNavController pushViewController:viewController animated:YES]; } And this is how I load the array with the plist: - (void)viewDidLoad { [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@"tier1Names" ofType:@"plist"]; tieroneArray = [[NSMutableArray alloc] initWithContentsOfFile:path]; NSString *tableURL = [[NSBundle mainBundle] pathForResource:@"tier1URL" ofType:@"plist"]; tieroneurlArray = [[NSMutableArray alloc] initWithContentsOfFile:tableURL]; }

    Read the article

  • NSURL Out of Scope

    - by ct2k7
    Hi, I've an issue with this piece of code: NSURL *url = [[NSURL alloc] initWithString:@"http://authenticate.radonsystems.net/products.xml"]; NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url]; //Initialize the delegate. XMLParser *parser = [[XMLParser alloc] initXMLParser]; //Set delegate [xmlParser setDelegate:parser]; //Start parsing the XML file. BOOL success = [xmlParser parse]; if(success) NSLog(@"No Errors"); else NSLog(@"Error Error Error!!!"); } // this is the breakpoint! I've listed where the breakpoint is - (I've placed one on every line of code in the area) Now at this point, success = NO, and looking back through the code, I reach the first line. XCode tells me that the url variable is out of scope with code 0x15db010. What does this mean?

    Read the article

  • objective c NSURL may not respond to +initFileURLWithPath

    - by caballo7
    I have two lines of code in the applicationDidFinishLaunching function: NSString *targetFilePath = @"/Users/bob/Documents/About_Stacks.pdf"; NSURL *targetFileURL = [NSURL initFileURLWithPath:targetFilePath]; and I am getting the warning (title) in the second line... I have no idea what I am doing wrong. This is an absurdly simply application... I have read other posts about reordering methods, but I am using classes provided by NS, nothing of my own. Any advice would be much appreciated. Thanks.

    Read the article

  • Testing file existence using NSURL

    - by Peter Hosey
    Snow Leopard introduced many new methods to use NSURL objects to refer to files, not pathnames or Core Services' FSRefs. However, there's one task I can't find a URL-based method for: Testing whether a file exists. I'm looking for a URL-based version of -[NSFileManager fileExistsAtPath:]. Like that method, it should return YES if the URL describes anything, whether it's a regular file, a directory, or anything else. I could attempt to look up various resource values, but none of them are explicitly guaranteed to not exist if the file doesn't, and some of them (e.g., NSURLEffectiveIconKey) could be costly if it does. I could just use NSFileManager's fileExistsAtPath:, but if there's a more modern method, I'd prefer to use that. Is there a simple method or function in Cocoa, CF, or Core Services that's guaranteed/documented to tell me whether a given file (or file-reference) URL refers to a file-system object that exists?

    Read the article

  • NSURL doesn't work any time

    - by Marco
    Hello community, i have the following problem sometimes my openURL-Dialog works perfectly, then i looked at the variable from the url and that is the variable: www.brehm-gmbh.de but some other times there are some crazy elements at the end of the variable like this: www.adamczyk-fenster.de%E2%80%8E i get this pages from an .asc file and both are in this file normal without this elements, what can i do to solve this problem? thank you all for helping beforehand

    Read the article

  • Comparing an [NSURL path] to an NSString doesn't work

    - by Koning Baard XIV
    I have this code: NSLog([url path]); if([url path] == @"/connect/login_success.html") { NSLog("IT WORKZ"); } When I run my application, do the login etc... my console says: 2010-05-04 23:49:57.297 Framebook Test Application[8069:a0f] /connect/login_success.html But it should also print IT WORKZ to the console, which it does not. Can anyone help me? Thanks.

    Read the article

  • How to make an NSURL that contains a | (pipe character)?

    - by aks
    Hi all, I am trying to access google maps' forward geocoding service from my iphone app. When i try to make an NSURL from a string with a pipe in it I just get a nil pointer. NSURL *searchURL = [NSURL URLWithString:@"http://maps.google.com/maps/api/geocode/json?address=6th+and+pine&bounds=37.331689,-122.030731|37.331689,-122.030731&sensor=false"]; I dont see any other way in the google api to send bounds coordinates with out a pipe. Any ideas about how I can do this?

    Read the article

  • iPhone SDK: Check validity of URLs with NSURL not working??

    - by Chris
    hi, I'm trying to check if a given URL is valid and i'm doing it like this: - (BOOL)urlIsValid:(NSString *)address { NSURL *testURL = [NSURL URLWithString:address]; if (testURL == nil) { return NO; } else { return YES; } } Since "URLWithString" is supposed to return "nil" if the URL is malformed I thought this would work but it doesn't for some reason. Could someone please tell me why? Thanks in advance!

    Read the article

  • Valid URL-string as NSUrl becomes null

    - by Mike
    Hello, another issue where I seem to have found an solution for ObjC but not MonoTouch. I want a NSUrl from an URL (as string). The string may contain whitespace and backslashes. Why is NSUrl returning null for such string, even though these are valid urls in a browser? For example: NSUrl foo = NSUrl.FromString(@"http://google.com/search?\query"); foo == null Any suggestions?

    Read the article

  • NSURL URLWithString: raises exception

    - by Stephen Darlington
    In short, [NSURL URLWithString:] appears to be raising an exception. According to the documentation "If the string was malformed, returns nil." There is no mention of an exception being raised under any circumstance. In addition to this, I am both encoding the URL and checking for nil before converting the string to a URL. Can anyone offer any advice as to which exception it could be or what other error checking I should be doing before converting the URL? In case you're interested in the details, the calling code looks like this: NSString* tmpText = [newUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; if (tmpText == nil) { // error handling } else { NSURL* tmpURL = [NSURL URLWithString:tmpText]; And this is a section from the crash report download from iTunes Connect: 8 libobjc.A.dylib 0x300c1f84 objc_exception_throw 9 CoreFoundation 0x3029a598 +[NSException raise:format:arguments:] 10 CoreFoundation 0x3029a538 +[NSException raise:format:] 11 Foundation 0x30696dde -[NSURL initWithString:relativeToURL:] 12 Foundation 0x30696cd8 +[NSURL URLWithString:relativeToURL:] 13 Foundation 0x30696cae +[NSURL URLWithString:] 14 Yummy 0x000146ca -[DeliciousPostCell setUrl:] + 46 It seems that the URL was in a "bad" format somehow but that should really be returning a nil not an exception. I have never seen the exception being raised myself so I can't use XCode to trap the code and see what's happening. And the user(s) that experienced the problem never contacted me directly so I can't ask for more details. Any suggestions greatly appreciated. Update (14/7/2009): Seems like such a hack, but I added an exception block around the suspect line. I also raised a Radar bug report (#7031551) suggesting that the code should match the documentation.

    Read the article

  • Objective-C and NSURL: where am I supposed to declare receivedData?

    - by jthomas
    I have a two classes, a controller called "AppController" and a class called "URLDelegate" that encapsulates the sample NSURL code from Apple's URL Loading System Programming Guide. The guide repeatedly mentions declaring the receivedData instance variable "elsewhere." I assume this means outside of the URLDelagate class, because if I declare it in the URLDelegate class, my controller class can't "see" the data that has been downloaded. I know that data is received, because in my connectionDidFinishLoading function, I have NSLog display the results: NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]); receivedText=[[NSString alloc] initWithData:receivedData encoding: NSASCIIStringEncoding]; NSLog(@"receivedText=%@",receivedText); So I'm a bit stumped with the following questions: Where should I declare receivedData? My controller class? A third class? Can I just declare it like any normal NSMutableData variable? How do I give my URLDelegate class "access" to this variable? E.g., if I declare receivedData in my AppController class, wouldn't I have to instantiate AppController within URLDelegate? But how would this possible if it's the AppController class which is instantiating the URLDelegate class in the first place? Especially with regard to the last question, I feel like I must be overlooking something blindingly obvious and fundamental. If anyone could point me in the right direction, I would really appreciate it. Thank you!

    Read the article

  • [[NSURL alloc] initFileURLWithPath:(NSString)] returns null

    - by Ajay Pandey
    NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"Opening" ofType:@"wav"]; NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; NSLog(@"@ajay"); AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil]; [fileURL release]; [audioPlayer play]; i have inserted a wav file in my project.But NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; returns NULL and console prints following: and application KILLS... Can someone help me?

    Read the article

  • NSURL not instantiating properly

    - by taokakao
    Hi, I am new to IPhone developing. I have got very strange issue with NSURL which is driving me crazy. I want to instantiate NSURL object to use it in loading image. But instantiation never happens in proper way. It always says my url in invalid. Basically I use code like below: NSString *str = @"http://google.com"; NSURL *url = [NSURL URLWithString:str]; but I also have tried a lot of different modifications (with CFStringRef + CFURLCreateStringByAddingPercentEscapes and so on). All of them are not working for me. In debugger url is set to "Invalid". What it could be? I don't think this is algorithmic or environment issue. It could be about some settings? Have anyone any idea of what happens?

    Read the article

  • Memory leaks with UIWebView and NSURL: already spent several days trying to solve them

    - by Sander de Jong
    I have already found a lot of information about how to solve memory leaks for iPhone Obj C code. The last two leaks keep me puzzled, I'm probably overlooking something. Maybe you can spot it. Instruments reports 2 leaks for the following code (part of a UIViewController subclass): (1) UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height - LOWER_VERT_WINDOW_MARGIN)]; (2) webView.scalesPageToFit = YES; (3) webView.dataDetectorTypes = UIDataDetectorTypeNone; (4) (5) NSURL *url = [NSURL fileURLWithPath:self.fullPathFileName isDirectory:NO]; (6) NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:url]; (7) [webView loadRequest:urlRequest]; (8) [urlRequest release], urlRequest = nil; (9) [self.view addSubview:webView]; (10) [webView release], webView = nil; Instruments claims 128 bytes are leaking in line 1, as well as 256 bytes in line 4. No idea if it means line 3 or line 5. Does anybody have a clue what I'm overlooking?

    Read the article

  • Press a Button and open a URL in another ViewController

    - by Dennis Borup Jakobsen
    I am trying to learn Xcode by making a simple app. But I been looking on the net for hours (days) and I cant figure it out how I make a button that open a UIWebView in another ViewController :S first let me show you some code that I have ready: I have a few Buttons om my main Storyboard that each are title some country codes like UK, CA and DK. When I press one of those Buttons I have an IBAction like this: - (IBAction)ButtonPressed:(UIButton *)sender { // Google button pressed NSURL* allURLS; if([sender.titleLabel.text isEqualToString:@"DK"]) { // Create URL obj allURLS = [NSURL URLWithString:@"http://google.dk"]; }else if([sender.titleLabel.text isEqualToString:@"US"]) { allURLS = [NSURL URLWithString:@"http://google.com"]; }else if([sender.titleLabel.text isEqualToString:@"CA"]) { allURLS = [NSURL URLWithString:@"http://google.ca"]; } NSURLRequest* req = [NSURLRequest requestWithURL:allURLS]; [myWebView loadRequest:req]; } How do I make this open UIWebview on my other Viewcontroller named myWebView? please help a lost man :D

    Read the article

  • Check if NSURL is Local File

    - by golfromeo
    This is a pretty simple question- how can I check if a NSURL is linking to a local file? I know, RTFM, but I checked the documentation and I don't seem to see any methods related to this. The only methods I did find were -isFileReferenceURL and -isFileURL, but I think these only check if the URL directly links to a file. note: I'm making an iPhone app, so by "local file" I mean a .html file stored in the project's resources. Thanks for any help in advance.

    Read the article

  • NSURL Connection will/won't load data

    - by jkap
    So here's my issue: I followed the NSURLConnection tutorial in the iPhone Developer Documentation almost to the T, and it only kinda works. Here's where it all goes wrong: The object seems to be created correctly and delegates to connectionDidFinishLoading, but with any URL I try to load the response data always ends up only being 0 bytes. I am running in the simulator if that makes any difference. Here's my relevant code: - (void)viewDidLoad { [super viewDidLoad]; self.title = @"WVFS Player"; //create a request NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://wvfs.josh-kaplan.com/nowPlaying.php"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; // create a connection NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if(theConnection) { // create the datum responseData=[[NSMutableData data] retain]; } else { // code this later } } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { // make it work NSLog(@"Succeeded! Received %d bytes of data:",[responseData length]); // release it [connection release]; [responseData release]; } And here's my log output: [Session started at 2010-03-14 09:01:09 -0400.] 2010-03-14 09:01:14.784 WVFS[19571:207] Succeeded! Received 0 bytes of data: Any ideas? Thanks, Josh

    Read the article

  • Why does fileURLWithPath: give me a file://localhost/ URL?

    - by jxpx777
    I have a project I'm working on and this seems like the simplest thing in the world, but the +[NSURL fileURLWithPath:] factory method is returning a strange URL. I created an empty sample project to isolate the problem and in my app delegate's applicationDidFinishLaunching: method I have this simple code: NSString *path = [@"~/Documents" stringByExpandingTildeInPath]; NSURL *url = [NSURL fileURLWithPath:path]; NSLog(@"%@ | %@", path, url); and the NSLog result looks like this: /Users/myusername/Documents | file://localhost/Users/myusername/Documents/ when I would expect the URL to be file:///Users/myusername/Documents. Any thoughts on why this is behaving like this? (10.6.3 in case it matters.)

    Read the article

  • Dialing a command prefix on the iPhone

    - by tewha
    Our application lets users call phone numbers. Users would like to be able to block their caller ID. On other platforms, we let the user specify a custom dialing prefix. For instance, on my cell provider it's #31#. I've tried two approaches so far. First: id url = [NSURL URLWithString: @"tel:#31#0000000"] // produces nil Second: id encoder = ["#31#0000000" stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; // produces %2331%230000000 id url = [NSURL URLWithString: [NSString stringWithFormat: @"tel:%@", encoded]]; // produces a valid-looking NSURL which doesn't do anything I'm thinking at this point that I'm just not allowed to dial # and *, even from a Cocoa touch application. (I know it's not allowed from a web app.) Is this true, or am I missing something obvious?

    Read the article

  • iPhone: ASIFormDataRequest Returns NULL from PHP Server

    - by meetS
    Hi, I have PHP script link, which responds YES or NO when we set post userName and emailID. I have used ASI framework. When I try to connect with the following code, I get a null return. NSURL *url = [NSURL URLWithString:@"https://abc.com/abctest/registration.php"]; ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:url]; [request setPostValue:@"[email protected]" forKey:@"email"]; [request setPostValue:@"pqr" forKey:@"userName"]; [request start]; NSError *error = [request error]; if (!error) { NSString *response = [request responseString]; printf("\n\n\n Responce %s",[response UTF8String]); response = [response stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ([response isEqualToString:@"YES"]) { printf("\n\n YES"); } } What am I doing wrong?

    Read the article

  • How to retrieve stored reference to an NSManagedObject subclass?

    - by DavidDev
    Hi! I have a NSManagedObject subclass named Tour. I stored the reference to it using this code: prefs = [NSUserDefaults standardUserDefaults]; NSURL *myURL = [[myTour objectID] URIRepresentation]; NSData *uriData = [NSKeyedArchiver archivedDataWithRootObject:myURL]; [prefs setObject:uriData forKey:@"tour"]; Now I want to retrieve it. I tried using: NSData *myData = [prefs objectForKey:@"tour"]; NSURL *myURL = [NSKeyedUnarchiver unarchiveObjectWithData:myData]; TourAppDelegate *appDelegate = (TourAppDelegate *)[[UIApplication sharedApplication] delegate]; NSManagedObjectID *myID = [appDelegate.persistentStoreCoordinator managedObjectIDForURIRepresentation:myURL]; if (myID) { Tour *tempObject = [appDelegate.managedObjectContext objectWithID:myID]; //WARNING tour = tempObject; } if (tour) //instruction... But it's giving me this warning "Incompatible Objective-c types. Initializing 'struct NSManagedObject *', expected 'struct Tour *' Plus, when executing, it's giving me this: Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0x5001eb0 How can I solve this?

    Read the article

  • Calculating File size before download - Downloading NSURLConnection Slider timing

    - by sagar
    Ok ! Coming to the point directly. What I want to do is explained as follows. I have an url of MP3 file. ( for example Sound File ) Now, When user starts application. Download should start & for that I have implemented following methods. -(void)viewDidLoad { [super viewDidLoad]; NSURL *url=[NSURL URLWithString:@"http://xyz.pqr.com/abc.mp3"]; NSURLRequest *req=[NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:120]; NSURLConnection *con=[[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:YES]; if(con){ myWebData=[[NSMutableData data] retain]; } else { // [MainHandler performSelector:@selector(targetSelector:) withObject:nil]; } } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@"%@",@"connection established"); [myWebData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"%@",@"connection receiving data"); [myWebData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"%@",@"connection failed"); [connection release]; // [AlertViewHandler showAlertWithErrorMessage:@"Sorry, there is no network connection. Please check your network and try again."]; // [self parserDidEndDocument:nil]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; } Now, Above methods work perfectly for downloading. But missing points are as follows. I can not get the exact size which is going to be downloaded. ( means I want to know what is the size of file - which is going to be download )

    Read the article

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