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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:44:04+00:00 2026-05-29T14:44:04+00:00

I’m using a function in my DBChartViewController.m file to pull in a value from

  • 0

I’m using a function in my DBChartViewController.m file to pull in a value from an SQLite database and pass it to another function in my draw2D.m file in order to draw a pie chart. The view displays initially, but never actually refreshes. Is there something wrong with this implementation?

Adding rest of files:

combinedDBandPieViewController.h

#import <UIKit/UIKit.h>
#import "/usr/include/sqlite3.h"
#import "draw2D.h"

@interface combinedDBandPieViewController : UIViewController {
    draw2D *pieChart;
}

@property (nonatomic, retain) draw2D *pieChart;

- (IBAction) findContact;
@end

combinedDBandPieViewController.m

#import "combinedDBandPieViewController.h"
@implementation combinedDBandPieViewController
@synthesize pieChart;
-(void)findContact
{
...code to search DB...
if (sqlite3_step(statement) == SQLITE_ROW)
        {
            NSString *pieField = [[NSString alloc] initWithUTF8String:(const char *)sqlite3_column_text(statement, 0)];
            self.pie.text = pieField;
            self.status.text = @"Match found";

            self.pieChart.ratio = [pieField floatValue];
            [self.pieChart setRatio:[pieField floatValue]];

        }
}

draw2D.h

#import <UIKit/UIKit.h>
@interface draw2D : UIView {
    @public float ratio;
}
@property (nonatomic,assign) float ratio;
-(void)setRatio:(float) newRatio;
@end

draw2D.m

#import "draw2D.h"
@implementation draw2D
@synthesize ratio;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
return self;
}

- (void)drawRect:(CGRect) rect{
    NSLog(@"Hurray Reached Here"); //Only comes up once, at boot
    int radius = 150;
    NSLog(@"%f", ratio);           //Only comes up once, displays 0.0000000
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, 8.0);

    CGRect rectangle = CGRectMake(84, 300, radius*2, radius*2);
    CGContextAddEllipseInRect(context, rectangle);
    CGContextSetFillColorWithColor(context, [UIColor greenColor].CGColor);
    CGContextFillPath(context);

    CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor);
    CGContextMoveToPoint(context, 234, 450);
    CGContextAddArc(context, 234, 450, radius, 0, -(M_PI * (2*ratio)), 1);
    CGContextFillPath(context);  
}

-(void)setRatio:(float) newRatio
{
    NSLog(@"Setting Ratio");
    ratio = newRatio;
    [self setNeedsDisplay];
}

- (void)dealloc
{
    [super dealloc];
}

@end
  • 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-29T14:44:06+00:00Added an answer on May 29, 2026 at 2:44 pm

    From what I see above you are trying to create a view that uses a ratio to display a pie chart. In this case you would want to use the ratio to control what your view renders. I would modify the code to make the ratio a property of your view and whenever the ratio property is changed the view refreshes itself.

    Expected behaviour

    - (void) findContact
    {
       ...code which pull value from database and displays correctly...
       NSString *passingPie = pieField;
       self.piechart.ratio = [passingPie floatValue];
    }
    

    .h file

    @interface PieChartView : UIView{
    
        @public
        float ratio;
    }
    @property (nonatomic,assign) float ratio;
    

    .m file

    @implementation PieChartView
    @synthesize ratio;
    
    - (void) drawRect:(CGRect)rect{
      int radius = 400;
      CGContextRef context = UIGraphicsGetCurrentContext();
      CGContextSetLineWidth(context, 8.0);
    
      CGRect rectangle = CGRectMake(184, 300, radius, radius);
      CGContextAddEllipseInRect(context, rectangle);
      CGContextSetFillColorWithColor(context, [UIColor greenColor].CGColor);
      CGContextFillPath(context);
    
      CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor);
      CGContextMoveToPoint(context, 384, 500);
      CGContextAddArc(context, 384, 500, 200, 0, -(M_PI * (2*ratio)), 1);
      CGContextFillPath(context);
    }
    
    - (void) setRatio:(float)newRatio{
      ratio = newRatio;
      [self setNeedsDisplay];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a reasonable size flat file database of text documents mostly saved in
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported

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.