Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6065263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:22:15+00:00 2026-05-23T09:22:15+00:00

This is the problem code: NSURL *url = [NSURL URLWithString:@http://photostiubhart.comoj.com/ReadGallery/stiubhart1readgallery.php]; NSError* error; NSString* sizeString

  • 0

This is the problem code:

NSURL *url = [NSURL URLWithString:@"http://photostiubhart.comoj.com/ReadGallery/stiubhart1readgallery.php"];
NSError* error; 
NSString* sizeString = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];
double myDouble = [sizeString doubleValue];
int myInt = (int)(myDouble + (myDouble>0 ? 0.5 : -0.5));

//Create an array to hold the URLS
NSMutableArray *myURLS;

//Initialize the array with nil
myURLS = [[NSMutableArray alloc] init];

NSLog(@"Here1");
//Add all the URLs from the server to the array
for (int i = 0; i <= myInt; i++){
    NSString *tempString = [[NSString alloc] initWithFormat : @"http://photostiubhart.comoj.com/GalleryImages/%dstiubhart1.jpg", i];
    [myURLS addObject: [NSURL URLWithString:tempString]];
    [tempString release];
}

myPhotos = [[NSMutableArray alloc] init];

for(int i = 0; i < myInt; i++){
    [myPhotos addObject:[myURLS objectAtIndex:i]];
}

It gives the error:

2011-06-21 22:20:47.167 CHARLIE[666:207] -[NSURL length]: unrecognized selector sent to instance 0x70418c0

This is what the code does (at least supposed to):

  1. Generate an integer from the contents of the URL (“4”).
  2. Use the integer in the for loops to add objects to arrays.

Can anyone tell me whats wrong here?

Thanks a lot,

Jack

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:22:15+00:00Added an answer on May 23, 2026 at 9:22 am

    If you want to add URLs as strings then shouldn’t this –

    for (int i = 0; i <= myInt; i++){
        NSString *tempString = [[NSString alloc] initWithFormat : @"http://photostiubhart.comoj.com/GalleryImages/%dstiubhart1.jpg", i];
        [myURLS addObject: [NSURL URLWithString:tempString]];
        [tempString release];
    }
    

    be –

    for (int i = 0; i <= myInt; i++){
        NSString *tempString = [NSString stringWithFormat:@"http://photostiubhart.comoj.com/GalleryImages/%dstiubhart1.jpg", i];
        [myURLS addObject:tempString];
    }
    

    You’re probably expecting them to be strings and later calling length method on them whereas they are stored as URLs in the array.

    Additionally, myPhotos seems to be a property in which case you can substitute –

    myPhotos = [[NSMutableArray alloc] init];
    
    for(int i = 0; i < myInt; i++){
        [myPhotos addObject:[myURLS objectAtIndex:i]];
    }
    

    with this –

    self.myPhotos = myURLS;
    [myURLS release]; // To balance out the earlier alloc-init
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an application, this: http://web.extebtion/projects/projectName/myaccount.php?1310625280.37+TE1PUFha-MDEyMzQ1Njc4OV85X3NpbXVsYXRvcg==+1310625280.37 (TYPE OF) URL is being tried to open by:
I'm trying to use ASIFormDataRequest with the following code: NSURL *url = [NSURL URLWithString:
Having a problem getting the URL for a resource for some reason: This code
I am having problem with xmlparsing with post method. API URL : http://XXX.XXX.X.XX/api/user.php Function
What is the best way to solve this problem in code? The problem is
i am a beginner and i have a problem : this code doesnt compile
I'll try to explain this problem the best way i can with code: double
Never thought I'd have this problem :) The following snippet of code works in
The easiest way to explain this problem is to show you some code: Public
I'm trying to solve this problem, its not a homework question, its just code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.