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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:34:21+00:00 2026-06-07T23:34:21+00:00

Can anyone tell me why [NSMutableArray count] is always returning (null) in the debug

  • 0

Can anyone tell me why [NSMutableArray count] is always returning (null) in the debug window? It is initialized, the matching letters are registering, but it still does not return anything but null.

@implementation NSString (Word)
-(NSMutableArray *)placeOfLetter: (char)letterAsked;{

    NSMutableArray *matchingLetters;
    matchingLetters=[[NSMutableArray alloc]init];
    int len=(int)[self length];
    NSLog(@"length of word: %i, letterAsked=%c",len,letterAsked);
    NSUInteger counter=[matchingLetters count];

    for (NSUInteger x=0; x<[self length]; x++) {
        if ([self characterAtIndex:x]==letterAsked){
            NSNumber *foundPosition = [NSNumber numberWithUnsignedInteger:x];
            [matchingLetters addObject:foundPosition];
            NSLog(@"found at place : %@",foundPosition);
            NSLog(@"counter: %@",counter);
        }
    }
    if ([matchingLetters count]<=0){
         NSLog(@"counter: %@",counter);
         NSLog(@"no letters ");
        return nil;
    }else{
        return matchingLetters;
    }
}
  • 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-07T23:34:23+00:00Added an answer on June 7, 2026 at 11:34 pm

    I assume you are referring to the counter variable? You are assigning the count of matchingLetters to this variable before adding any elements, so at this point it is of course being assigned 0.

    When you later NSLog() the value of counter, it will still be 0. There is no automatic update mechanism that would magically update counter with the new count of matchingLetters once you’ve added elements to this array. And it displays as (null) because you’re using %@ instead of %qu.

    If that’s not what you’re referring to, are you perhaps referring to breaking your application in the debugger and then entering p -[matchingLetters count]? Or are you referring to part of the variables display on the left side of the debugging console (if so, a screenshot of what you’re seeing might be helpful)?

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

Sidebar

Related Questions

Can anyone please tell me how to write NSMutableArray of custom class objects to
Can anyone tell me what is the null value representation in mit-scheme? In the
Can anyone tell me why this is NULL ? So Array1 is NSMutable, and
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
Can anyone tell me why my Id always gets a zero added at the
Can anyone tell me why this code is returning undefined . I was hoping
Can anyone tell where i am wrong because its just a simple process but
Can anyone tell me why I can't return a NSMutableArray there: -(NSMutableArray)makeServiceRequest:(UIViewController *)sender {
Can anyone tell me why this code would not be working? $('body').on('test', function() {
can anyone tell me how to select data by date in MS.ACCESS database using

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.