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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:53:23+00:00 2026-05-24T08:53:23+00:00

my question is…. I can read data (x,y coordinate) from xml file, but, i

  • 0

my question is….

I can read data (x,y coordinate) from xml file, but, i don’t understand how i can put them in a drawrect method for drawing paths. In the specific, i have build, by interface builder, a label, a view and a button. My goal is: Click on the button and paths are drawn.

I would like to know how to link xml data and drawrect method .

Thx for helping me, and sorry for my easy english (i’m italian)

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

    First you need to keep the coordinates you read from the XML around in some data structure, maybe an NSArray. Since NSArray only wraps Objective-C objects, you can’t simply add an NSPoint to it. You need to wrap the point inside the NSValue object using [NSValue valueFromPoint: …].

    If you have your array of points, in the drawRect: of your view you could write:

    NSBezierPath * path = [NSBezierPath path];
    BOOL first = YES;
    for (NSValue * v in points) {
        if (first)
            [path moveToPoint:[v pointValue]];
        else
            [path lineToPoint:[v pointValue]];
        first = NO;
    }
    [path closePath];
    [path stroke];
    

    This will use the points stored in the NSArray called points to fill an NSBezierPath with information. NSBezierPath is the class used for describing geometric figures and drawing them.

    If you don’t want the first and the last point to be connected by a line, remove the [path closePath] instruction. If you’d rather have your path filled with the current color, change [path stroke] to [path fill].

    If you want to change the color of your path, put a [[NSColor blueColor] set] before the stroke/fill command, substituting your preferred color.

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

Sidebar

Related Questions

Question: I need to read a CSV file. I use the FileHelpers library to
Question How can I remove empty xml tags in PHP? Example: $value1 = 2;
Question is probably pretty basic, but can't find out what's wrong (and it leads
Question Can I build a image database/library that has an e-commerce style checkout system
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
Question How can I animate and form rows together? Explanation One 'for loop' is
Question follows on from Fluent NHibernate + multiple databases (no need to follow this
Question: I have a dll that I can load in another program. Now the
Question I'm creating a service for my app, but there's probably pritty simple thing
Question: How do you get a video thumbnail for an application-private file? Specifically, is

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.