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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:29:17+00:00 2026-06-15T18:29:17+00:00

I have a UIView called Product , which contains a sub UIView called Postcode

  • 0

I have a UIView called Product, which contains a sub UIView called Postcode.

In the Postcode UIView i have a simple form (one UITextField and one UIButton).

When the UIButton is clicked a method (called -storeData) is run inside postcode view … which works as intended.

Now inside storeData I would like to call a method in the superview Product.

This is what i tried doing, but im getting a warning:

if ([[self superview] class] == [ProductView class]) {
        ProductView *p = [self superview]; 
        [p handlePostChange]; 
    }

// Get this warning from this line ProductView *p = [self superview];

PostView.m:124:28: Incompatible pointer types initializing
‘ProductView *__strong’ with an expression of type ‘UIView *’

  • 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-06-15T18:29:18+00:00Added an answer on June 15, 2026 at 6:29 pm

    The call to [self superview] returns a UIView pointer. You are trying to do the equivalent of:

    UIView *view;
    ProductView *p = view;
    

    The compiler has no way to know that at runtime, view will really be of type ProductView. This is why the compiler complains.

    The solution, as was stated, is to use a cast:

    UIView *view;
    ProductView *p = (ProductView *)view;
    

    The cast tells the compiler “hey, don’t worry, I know what I’m doing. It really is a ProductView“. Of course if you are wrong, the app will most likely crash at runtime.

    The following is perfectly fine:

    ProductView *p;
    UIView *view = p;
    

    This is safe, gives no warning, and requires no cast. This works because it is known that ProductView is a subclass of UIView.

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

Sidebar

Related Questions

I have a UIView called activityView , which contains two subviews activityIndicator and cancelOperationsButton
I have a custom UIView called TiledImage which has a single property named tiledImage
So I have a UIView called footerView which is added to a UIScrollView. I've
I have a UITableViewController which has a UIView* called errorView that is used to
I have 3 pickers on my view, one of which contains only images. So,
I have a class that subclasses UIView called DrawView. This class contains custom drawing
I have a UIView that I call second inside another UIView called one. At
I have created a UIView called ImageShowcase which has a UIScrollView and then i
I have a UIView that contains a subview called menuView managed by a MenuViewController.
I have a UIView and UIButton (declared in viewDidLoad: method of RootViewcontroller. ). UIView

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.