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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:30:27+00:00 2026-05-27T10:30:27+00:00

I have a workaround for my problem, but I really want to understand why

  • 0

I have a workaround for my problem, but I really want to understand why I’m having this problem and how to solve it.

I have an entity A related to another entity B, and some of the rows of A have a special mark in one field.

I want to count how many of those A that are related to B, have this special mark.

All works perfectly, if after I create the NSSet I count the set:

NSSet *productsSet = currentList.ingredients;

int countProducts = productsSet.count;

NSPredicate *predicate = [NSPredicate predicateWithFormat: @"self IN %@ AND isInList = %d", productsSet,1];

[fetchRequest setPredicate:predicate];

int totalProductsInList = [context countForFetchRequest:fetchRequest error:error];

If I comment the
int countProducts = productsSet.count;
I have those errors:

-[NSNull unsignedIntValue]: unrecognized selector sent to instance 0x22b9cd8
2011-12-05 12:10:41.418 xxxxxxxxxx[32964:1bb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[NSNull unsignedIntValue]: unrecognized selector sent to instance 0x22b9cd8'

isInList is a Int16

thanks,

EDIT:

If I move the 1 inside the NSPredicate, without a count, I get the same error:

[NSPredicate predicateWithFormat: @"self IN %@ AND isInList = 1", productsSet;

EDIT 2:

As I can’t find why it doesn’t work, I check for productsSet.count and if it’s greater than 0 I make the NSFetchrequest, problem solved.

  • 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-27T10:30:28+00:00Added an answer on May 27, 2026 at 10:30 am

    Well, after creating the NSSet I check for nsset.count, and in case it’s greater than zero I issue the NSFetchrequest, in case it’s zero, don’t.

    Problem solved, but I still have the curiosity for this strange error that I have if I don’t use the nsset.count.

    thanks,

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

Sidebar

Related Questions

This may seem a bit odd, but I really need to create a workaround
I'm trying really hard to made this work, but I'm having no luck. I'm
I would really appreciate some help. I have a problem with html markup in
I have a problem as follows: We're using a rich text editor (TinyMCE, but
I have a jQuery problem, and I've really tried everything I know (i am
I have some problem with generics, let me explain. I have a class which
I've got a problem... (Really? :-) ) What I want to do? I need
WorkAround: I have declared a class level Public static variable and initialized with a
When we have new in C#, that personally I see only as a workaround
Since batch doesn't really have ints, I have to work around it with set

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.