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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:52:22+00:00 2026-06-07T20:52:22+00:00

I am trying to write a method for a new class called word, which

  • 0

I am trying to write a method for a new class called “word”, which is a subclass of NSString. I want a method that will accept a NSString containing a single character and return the the place within the word of every instance of that string. I have this so far:

@implementation Word
    -(NSMutableArray *)placeOfLetter: (NSString *)letterAsked;{
        NSUInteger *len=(NSUInteger *)[self length];
        int y=0;
        char letter=(char)letterAsked; 

        for (NSUInteger *x=0; x<len; x++) {
                if ([self characterAtIndex:*x]==letter){
                     [matchingLetters insertObject:x atIndex:y];
                     y++;
                }
        }
    }     
@end

however, xcode is telling me that I cannot put x as a the parameter for insertObject, because the “implicit conversion from NSUInteger to id is disallowed. How can I get around this?

  • 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-07T20:52:23+00:00Added an answer on June 7, 2026 at 8:52 pm

    The problem you’re encountering is stemming mostly from your treating NSUInteger as a pointer; you have some other casting problems as well. Try the following:

    • Instead of taking a full string for the letterAsked argument, then getting a char out of it, just get a char (or unichar) as your argument to begin with. You avoid the letter = (char)letterAsked conversion altogether.
    • Don’t make len a pointer. You may not need to declare len at all. Consider writing your for loop like:

      for(NSUInteger x = 0; x < [self length]; x++) { // ...
      

      This also helps you in the -characterAtIndex: call; you no longer need to dereference x in order to get the character.

    • Like Hot Licks said in the comments, use an NSNumber if you want a position inside an NSArray; you need numbers to be class instances to go in an NSArray instance. You can create an NSNumber out of x like this:

      NSNumber * foundPosition = [NSNumber numberWithUnsignedInteger:x];
      
    • Consider just using NSMutableArray’s -addObject: method, rather than keeping track of y and incrementing it each time. You’ll get the same result.

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

Sidebar

Related Questions

I'm trying to write a method that will compute all permutations of a power
I'm new to Android and SQLite, too. I'm trying to write a method where
I am trying to write a method in Java that accepts a string as
I am trying to write a method that adapts to different types of interfaces
I'm trying to write a method that removes all non alphabetic characters from a
I'm trying to write a method that acts as a setter and takes some
I am trying to write a method, that takes a ComboBox, a DataTable and
I am trying to write a method that makes a log.txt file if one
I'm trying to write a test for this class its called Receiver : public
I'm trying to write an application which will populate an array with random numbers.

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.