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

  • SEARCH
  • Home
  • 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 6133959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:17:46+00:00 2026-05-23T17:17:46+00:00

Want i want to do is i get a number from a php script.

  • 0

Want i want to do is i get a number from a php script. This number determines the labels that have to be added to the view. The php script is very simple and is the following:

<?php

echo (int)5;

?>

The objc script has to determine the number and needs to write as many labels als the php script describes. I am showing the string in another label to be sure that the number is being returned. How do i write those labels to my view?

I got some code as follows:

- (void)viewDidLoad
{
    NSString *post = @"";
    NSData *postData = [post dataUsingEncoding:NSISOLatin1StringEncoding allowLossyConversion:NO];
    NSMutableURLRequest *urlRequest = [[[NSMutableURLRequest alloc] init] autorelease];
    [urlRequest setURL:[NSURL URLWithString:@"http://......./testGet.php"]];
    [urlRequest setHTTPMethod:@"POST"]; 
    [urlRequest setHTTPBody:postData];


    NSData *urlData; 
    NSURLResponse *response; 
    NSError *error;
    urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error]; 
    if(!urlData) {
        NSLog(@"No connection!");
    }

    NSString *aStr = [[[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding]autorelease]; 


    int i;
    i = [aStr intValue];
    status.text = [NSString stringWithFormat:@"%d",i];

    for (int i; i <= 10; i++)
    {

        UILabel *mijnlabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 100)];

        mijnlabel.text = @"Loremipsum";
        [self.view addSubview:mijnlabel];
    }

    [super viewDidLoad];
}
  • 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-23T17:17:46+00:00Added an answer on May 23, 2026 at 5:17 pm

    Although your labels will all display at the same position, you are right to do so by sending [self.view addSubview:mijnlabel]; to the view.

    You have to be careful on these few things :

    1. The way you right your loop, use as the counter, another variable rather than the value you parsed from the string.
    2. Don’t forget to release the UILabelyou initialized just after adding it to the view.
    3. Send viewDidLoad first to the super view.

    So your might result to :

    // first
    [super viewDidLoad];
    
    ...
    
    NSString *aStr = [[[NSString alloc]
                       initWithData:urlData
                           encoding:NSUTF8StringEncoding]autorelease]; 
    int labelsCount = [aStr intValue];
    status.text = [NSString stringWithFormat:@"%d",labelsCounts];
    // another way, in order to display the label under each other
    // this will display labelsCount labels
    int i;
    for(i = 0; i < labelsCount; i++) {
        CGFloat yCoord = i * 100;
        UILabel *mijnlabel = [[UILabel alloc]
                              initWithFrame:CGRectMake(50, yCoord, 200, 100)];
        mijnlabel.text = @"Loremipsum";
        [self.view addSubview:mijnlabel];
        [mijnLabel release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have PHP script that fetch messages from a mailbox. I use the imap_search
I have a large number of 2D points and I want to quickly get
I want to get the number of Registrations back from a time period (say
I have a PHP script that inserts rows into a table based on selected
I'm trying to write a PHP script that gets my total unread count from
I am writing a script in PHP to get data from the twitter API,
I want to get the number of seconds since midnight. Here is my first
FromIp contains 192.168.1.1 . I want to get the last number, but I can't
In ML i want to get the prime divisors of a number. How can
dim dataType as String toolTip=Marks And Number[String] I want to get the [String] alone.

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.