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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:24:50+00:00 2026-06-10T08:24:50+00:00

so I have a little experience with objective-c, but not a ton. I’m trying

  • 0

so I have a little experience with objective-c, but not a ton. I’m trying to render UIBezierPath via TouchEvents (in other words draw a line with your finger). In addition, I would like to save all the bezierPaths into a NSMutableArray (paths) so that I can move or modify them later. This is the very simplest of applications. My header looks like this:

@interface ViewController : UIViewController{
    UIBezierPath* path;
    NSMutableArray* paths;

    int curThickness;

}

@property (strong, nonatomic) IBOutlet UIView *scene;
@end

Scene is the view which takes up the entire screen and is where I am trying to draw my paths.

Relavent implementation looks like this:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch = [touches anyObject];
    NSLog(@"Starting Path");

    path = [UIBezierPath bezierPath];
    path.lineWidth = 15.0f;
    path.lineCapStyle = kCGLineCapRound;
    path.lineJoinStyle = kCGLineJoinRound;
    path.flatness = 2.0;
    path.miterLimit = 4.0;

    [path moveToPoint:[touch locationInView:scene]];

}


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch = [touches anyObject];
    [path addLineToPoint:[touch locationInView:scene]];
    [scene setNeedsDisplay];
}


- (void)drawRect:(CGRect)rect {
    NSLog(@"I'm supposed to be drawing something...");
    [[UIColor redColor] set];
    [path stroke];
}



- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"No more touchy feelies");
    UITouch *touch = [touches anyObject];
    [path addLineToPoint:[touch locationInView:scene]];
    [paths addObject:path];
    [scene setNeedsDisplay];

    NSLog(@"number of paths: %i.", paths.count);

}

When I run it on the emulator, all the events are registered, DrawRect is never called, nothing is drawn on the screen (even if I add a [path trace] at the end of touchesEnded), path is nonEmpty, and paths.count remains zero no matter how many paths I trace.

What am I missing? As always your help is always greatly appreciated.

  • 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-10T08:24:52+00:00Added an answer on June 10, 2026 at 8:24 am

    Couple things that should help you:

    1. UIViewController does not implement - (void)drawRect .. you need to be doing this code in a UIView subclass instead!

    2. If your paths collection is always zero count, a common mistake causing this is when paths itself is nil. (Obj-c doesn’t care if you try to send messages to a nil object, it will just return a default value instead of crashing.) Double-check that you instantiated an NSMutableArray object and pointed paths to it.

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

Sidebar

Related Questions

I've compiled C# code into a DLL, but have little experience with them. My
I have very little experience using Sharepoint but a good amount using Visual Studio
I have a strong database background but very little practical experience with ms sql
I have 0 experience with python, very little with regex and I'm trying to
I have little experience with silverlight development still but with the potential of silverlight
This looks very simple but I have little experience with jQuery and I can't
I know this question is simple, but I have little experience with arrays and
I'm new to C++, I have lots of Objective-C experience. I'm trying to have
I have used Jetty in the past but I have little experience with jWebSocket.
OBJECTIVE: To learn a little more about some technologies I'm familiar with but not

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.