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 7614517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:25:23+00:00 2026-05-31T02:25:23+00:00

I’m working on a little quiz app, and I was working on an algorithm

  • 0

I’m working on a little quiz app, and I was working on an algorithm to quickly proceed to the next question. The first part of the code was adequate. It worked well, but the last line threw an error. I was wondering if you could use an NSString to access a UIView variable. Here’s the code:

NSString *QuestionString = [NSString stringWithFormat:@"%d", Question]; // THE "Question" VARIABLE IS AN INT...
NSString *PlayViewString = [NSString stringWithFormat:@"%@", @"PlayView"];
NSString *ThePlayViewString = [PlayViewString stringByAppendingString: QuestionString];
NSLog(@"%@", ThePlayViewString); //WORKS GREAT TO HERE (Logged to make sure everything went well)

self.view = ThePlayViewString; // THROWS ERROR "Incompatible pointer types assigning from 'UIView *' to 'NSString *'"

UPDATE

The algorithm is inside a IBAction for a UIButton. It’s meant so that whenever you press the button, or in further questions any other object, you’ll proceed onto the next question. Thank you all for establishing that I CAN NOT use a NSString to get to a UIView.

Thanks for your help!

  • 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-31T02:25:25+00:00Added an answer on May 31, 2026 at 2:25 am

    its quite clear what happens..

    1. NSLog(ThePlayViewString, @"%@"); iplain wrong way round, it should be
      NSLog(@"%@",ThePlayViewString, );

    2. self.view = ThePlayViewString; gives you the error "Incompatible pointer types assigning from 'UIView *' to 'NSString *'"

    from this error it should be absolutely clear what is wrong. self.view is of type UIView * and if you want to assign something to it, it has to be of type UIView * as well. you cannot assign a string to a view.

    Solution:

    if you do not know how to create a view, this is where to look: create a view programmatically

    you could create your views with .xib files (interface builder), name them after your questions and open them with the string, like that:

    self.view = [[UIView alloc]initWithNibName:ThePlayViewString bundle:[NSBundle mainBundle]];
    

    Edit for your purpose:

    i would use another approach to what you are trying to do.

    1. put all questions in an NSArray like that

      NSArray * array = [[NSArray alloc]initWithObjects: @”question 0″, @”question 1″, …, nil];

    2. get your question number as before

    3. get the next question

      NSString *nextQuestion = [[array objectAtIndex: questionNumber]]; (questionNumber must be type int)

    and display it in a label:

    UILabel *mylabel = [[UILabel alloc]init];
    [mylabel setText:nextQuestion];
    

    i would use interfacebuilder to make a label with a connection.
    sebastian

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm making a simple page using Google Maps API 3. My first. One marker

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.