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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:54:52+00:00 2026-06-04T19:54:52+00:00

I am having some extreme difficulty with this using blocks and inheritance. I declared

  • 0

I am having some extreme difficulty with this using blocks and inheritance.

I declared a block in .h file:

void (^block)(BOOL);

initialize it in .m:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        block = ^(BOOL noshow)
        {
            if(noshow){
                AutoTracView.hidden = YES;
                MarineTracView.hidden = YES;

            }
        };
    }
    return self;
}

Now I pass it as well as UIVIEw instances to a category of UIViewController:

NSDictionary *const collection = [NSDictionary dictionaryWithObjectsAndKeys: //make global
                                  @"1", AutoTracView,
                                  @"2", MarineTracView,
                                  nil];

[self renderView:[current_unit.unit_type intValue] onCollection:(NSDictionary *)collection withBlock:block];

In UIViewController+extensions.m:

-(void)renderView:(int)value onCollection:(NSDictionary *)collection withBlock:block
{
    block(TRUE);
    NSString *index = [NSString stringWithFormat:@"%d", value];
    UIView *view = [collection objectForKey:index];
    view.hidden = NO;    
}

Unfortunately, block(TRUE) throws a compile error: “called object type id is not a function or function pointer”

ok, so I get desparate, and just try to get the block thing working so i remove the block as a parameter call. and just call it within the controller which does work. But then another problem arises:

NSDictionary *const collection = [NSDictionary dictionaryWithObjectsAndKeys: //make global
                                  @"1", AutoTracView,
                                  @"2", MarineTracView,
                                  nil];

It fails with that above saying:

-[UIView copyWithZone:]: unrecognized selector sent to instance 0x6ee2b80
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView copyWithZone:]: unrecognized selector sent to instance 0x6ee2b80'

Am I not allowed to pass my UIView instances around?

Here is the header file for that:

@property (weak, nonatomic) IBOutlet UIView *AutoTracView;

@property (weak, nonatomic) IBOutlet UIView *MarineTracView;

Im feeling trapped right now in doing anything. This might seem like a two part question but really i abandoned the concept of passing blocks and just looking for ideas on the error “[UIView copyWithZone:]: unrecognized selector sent to instance “

  • 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-04T19:54:54+00:00Added an answer on June 4, 2026 at 7:54 pm

    One issue is your call to dictionaryWithObjectsAndKeys:. I think you want to make the UIViews the objects, and the number strings the keys, but the way you’ve coded it, you’re making the strings the values and the UIViews the keys. UIView doesn’t implement NSCopyable, so they can’t be used as keys. You should reverse the order in your call, like so:

    NSDictionary *const collection = [NSDictionary dictionaryWithObjectsAndKeys: //make global
                                      AutoTracView, @"1",
                                      MarineTracView, @"2",
                                      nil];
    

    Really, if all you want to do is give them numeric indexes, you could use an NSArray instead of an NSDictionary, but there’s no reason it won’t work either way.

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

Sidebar

Related Questions

Having some issues running my code local. I have host file setup like this:
I'm having some rather extreme difficulty getting HDF5 1.8.7 to build from source in
Having some problems with getting some ajax script to work. Using this as the
I'm developing a Vaadin application and am having extreme difficulty getting some aspects of
Im having some problems with redirections. Im using primefaces and JSF 2.1. The thing
Having some difficulty understanding the best way to implement subclasses with a generic repository
Having some problems with IE7 on jquery $.each, this gives me an Object does
Having some layout frustrations in WPF- I'm using a ToolBar to house a set
Having some trouble getting this query to work correctly. mysql_query(DELETE FROM `table` WHERE `id`
Having some issues with this search engine I am trying to put together. I'll

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.