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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:57:32+00:00 2026-06-08T18:57:32+00:00

Overview I have painting APP. It registers mouse events and sends it to NSMutableArray.

  • 0

Overview

I have painting APP. It registers mouse events and sends it to NSMutableArray. Later values from array are being transfered to GLfloat and drawn like vertex array. So all brush stroke is redrawn at every mouse event.

What I want to do?

I want to implement undo-redo functions and something like brush stroke variety (softness and etc), so I need somehow to do that every vertex (mouse event location) could have few additional settings. I want to ask if it is possible at all.

Explanation

If user draws 10 points with 100% softness (in one mouse drag) and then changes softness to 0% and draws, first 10 point’s brush texture has to be set to img1 and second brush stroke brush’s texture has to be set to img2.

If there would be possibility for indexing arrays (for example something like this NSMutableArray *array[i++] = [[NSMutableArray alloc] init]) I think it would be possible to do something similar to what I want pretty easy. But is it possible? Or maby you could suggest any other solution?

P.S. NSMutableArray *array[i++] = [[NSMutableArray alloc] init] doesn’t shows me any error, but does’t works too.


Attempt using NSMutableDictionary

At mousedown and mousedragged:

locll = [self convertPoint: [event locationInWindow] fromView:nil];
NSValue *locationValuell = [NSValue valueWithPoint:locll];
[vertices addObject:locationValuell];

at mouseUp

NSString *index = [NSString stringWithFormat:@"%d", aIndex++];
[aDict setObject:vertices forKey:index];
NSArray *allKeys = [aDict allKeys];
NSLog(@"dict count: %ld", [allKeys count]);
NSString *index1 = [NSString stringWithFormat:@"%d", aIndex];
NSMutableArray *a = [aDict objectForKey:index1];
NSLog(@"a count:%li", [a count]);

at initWithCoder

int aIndex = 0;

dict count returns how many objects are stored in dictionary. And it works. But later when I try to get array back from dictionary, I check how much objects array has and it returns 0.

  • 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-08T18:57:34+00:00Added an answer on June 8, 2026 at 6:57 pm

    If i understand your question right , here’s what you can do :

    • Every mouse drag will be 1 path i.e an NSMutableArray of points
      with same softness level.
    • Add this to a NSMutableDictionary with Key as the
      softness-level and Value with this path array.
    • Iterate through the dictionary to get the corresponding Key-Value
      pair and draw the strokes.
    • For UNDO just delete the last object of the dictionary and store in
      a temporary dictionary.
    • For REDO fetch it back from the temporary dictionary and add to the main dictionary.

    Thanx for posting the code. I tried this and it works absolutely fine :

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        int aIndex = 0;
        NSMutableDictionary *aDict =[[NSMutableDictionary alloc]init];
        NSMutableArray *vertices = [[NSMutableArray alloc]init];
        [vertices addObject:@"one"];
        [vertices  addObject:@"two"];
        [vertices addObject:@"three"];
    
        NSString *index = [NSString stringWithFormat:@"%d", aIndex++];
        [aDict setObject:vertices forKey:index];
    
        NSArray *allKeys = [aDict allKeys];
        NSLog(@"dict count: %d", [allKeys count]);  // Prints 1
    
        NSMutableArray *a =[aDict objectForKey:index];
        NSLog(@"a item count is :%d", [a count]);   // prints 3
    }
    

    NOTE: Be careful with the index you are passing.

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

Sidebar

Related Questions

Overview I have an iOS app which sends local notifications at specific dates. I
Overview: I have a Silverlight 4 app where I am seeing problematic behavior from
I have a overview page containing a list with some links from which multiple
Sitation: overview: I have something like this: std::vector<SomeType> values; std::vector<int> indexes; struct Range{ int
Overview: I have an array of 20 byte strings that needs to be stored
Overview So I have pulled out a document from my database. Inside is a
Overview: I have a SWF banner ad template which loads in JSON from a
Overview: I have an advancedDataGrid that I am using a GroupingCollection on and I
Overview I have an iOS project which contains 2 navigation controllers as shown in
I have an overview drawing of a plant and I want to show the

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.