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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:02+00:00 2026-05-22T20:51:02+00:00

It must be one of those things where there’s a tiny mistake i’ve missed,

  • 0

It must be one of those things where there’s a tiny mistake i’ve missed, or something, but i can’t seem to figure it out.

Viewcontroller.h

#import "RGBEditView.h"
@interface ColorPickerView : UIViewController {
RGBEditView *rgbEditView;
}
-(void)showRGBEditor;

.m

-(void)showRGBEditor {
rgbEditView = [[RGBEditView alloc] initWithFrame:CGRectMake(0, 0, 280, 46) H:h S:s B:b];
}

It’s this line above, the initwithframe line, that gives the error 'Incompatible Objective-C types assigning '*', expected '*'

RGBEditView.h

@interface RGBEditView : UIView {
}
-(RGBEditView *)initWithFrame:(CGRect)frame H:(float)hue S:(float)saturation B:(float)brightness;

RGBEditView.m

-(RGBEditView *)initWithFrame:(CGRect)frame H:(float)hue S:(float)saturation B:(float)brightness {
[super initWithFrame:frame];
 return self;
}

Can anybody see my problem? I’m very confused about this.

EDIT:

The problem lies in that I have another class which also uses initWithFrame:H:S:B:, so the only way to fix this is to change on of them to something a bit different, but this seems like an awkward work around. Any other solutions?

  • 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-22T20:51:03+00:00Added an answer on May 22, 2026 at 8:51 pm

    the methods init and methods that start with initWith should return type id.

    what typically happens is that you have 2 classes with the same method name (initializer in this case), but differ in their return types:

    RGBEditView

      -(RGBEditView *)initWithFrame:(CGRect)frame H:(float)h S:(float)s B:(float)b;
    

    HSBEditView

      -(HSBEditView *)initWithFrame:(CGRect)frame H:(float)h S:(float)s B:(float)b;
    

    alloc returns id – the compiler warns you because it sees an expression which resembles type assignment used in the following example:

    RGBEditView * rgb = /* ... */;
    HSBEditView * hsb = nil;
    hsb = rgb // << compiler: "hey - you don't want to do that unless
              //               RGBEditView were a subclass of
              //               HSBEditView... but it's not!"
    

    you correct this by returning id from your initializers, like this:

    -(id)initWithFrame:(CGRect)frame H:(float)h S:(float)s B:(float)b;
    

    you return id to avoid clashes like this, and because the compiler doesn’t know what type is returned via alloc, so every subclass declaration would have to return a different type – which would only lead to more problems.

    the exception to this is to use well qualified names – and is typically seen in convenience constructors:

    + (HSBEditView *)newHSBEditViewWithFrame:(CGRect)frame
                                           H:(float)h S:(float)s B:(float)b;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came with below solution but I believe that must be nicer one out
I feel stupid for asking, but there must be a one liner that does
I must apologize if this is a duplicate question, but I can't seem to
One car must have one owner, and an owner can have many cars.
This is one of those things, that maybe so simple I'll never find it
I am making an application which is almost done but there is one thing
Here's one of those ColdFusion things that seems like it should be so easy...
In a few days, I must make one complex commit, I'll try to explain
I have lots(+2000) of GUIDs(in some network class) and my program must find one
I've found a task on some Java programming competition. One must create class Sentence

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.