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

  • Home
  • SEARCH
  • 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 6807431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:49:54+00:00 2026-05-26T19:49:54+00:00

#import DotAnimation.h @implementation DotAnimation DoodlePad* dp; -(void)setupView { Ball = CGRectMake(10, 10, 10, 10);

  • 0
    #import "DotAnimation.h"


@implementation DotAnimation
DoodlePad* dp;

-(void)setupView {
    Ball = CGRectMake(10, 10, 10, 10);
    [NSTimer scheduledTimerWithTimeInterval:(1.0f / 30.0f) target:self selector:@selector(traceBall) userInfo:nil repeats:YES];
}

-(id)initWithCoder:(NSCoder *)aDecoder {
    if (self == [super initWithCoder:aDecoder]){
        [self setupView];
    }
    return self;
}

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


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.*/
- (void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [[UIColor yellowColor] CGColor]);
    CGContextFillEllipseInRect(context, Ball);

}
-(void)traceBall{
    vector<CGPoint>::iterator L = dp.doodlePoints->begin();
    while(L != dp.doodlePoints->end()){
        Ball.origin.x += (*L).x;
        Ball.origin.y += (*L).y;
        ++L;
    }
    [self setNeedsDisplay];
}

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

@end

I have this Animation I am trying to use in another file.
So i figure i do something like

trace = [[DotAnimation alloc]initWithCoder];

or

trace = [[DotAnimation alloc]initWithFrame];

I am unsure which one to use or if i am even writing this correctly.

I want to be able to use:

    while(k != dp.doodlePoints->end()){
    Ball.origin.x += (*k).x;
    Ball.origin.y += (*k).y;
    ++k;
}

In another file but I don’t know how to call Ball.origin from DotAnimation

Also it would be great if you could link me to good information on understanding 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-05-26T19:49:54+00:00Added an answer on May 26, 2026 at 7:49 pm

    initWithCoder is called by the framework when you embed an object into a XIB. Like a ViewController for example. So you should not call it by yourself.

    Calling initWithFrame could be a better solution if you want to set the frame (like that seems to be done here). But you may give a frame, and add a subview created by yourself.

    if you don’t want to create the subview by yourself, then it’s initWithNibName:bundle: that you may call/override. Creating the XIB that contains the view. But you will still need to add that view as subview to the main view that is showing that animated view.

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

Sidebar

Related Questions

import java.lang.Math; public class NewtonIteration { public static void main(String[] args) { System.out.print(rootNofX(2,9)); }
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class DateDemo { public static void main(String[]
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; public class Filereader { public static void main(String[]
import wx class MainFrame(wx.Frame): def __init__(self,parent,title): wx.Frame.__init__(self, parent, title=title, size=(640,480)) self.mainPanel=DoubleBufferTest(self,-1) self.Show(True) class DoubleBufferTest(wx.Panel):
import inspect class Test: def test(self, p, d={}): d.update(p) return d print inspect.getargspec(getattr(Test, 'test'))[3]
import javax.swing.*; import java.io.File; public class Third { public static void main(String[] args) throws
import wx import wx.grid as gridlib ######################################################################## class PanelOne(wx.Panel): #---------------------------------------------------------------------- def __init__(self, parent): Constructor
import java.util.*; public class Test { public static void main(String[] args) { List db
import java.util.ArrayList; import java.util.Random; public class Generator{ //9352141NTBG1223 public static void main(String[] args) {
import java.io.*; public class ThreadSanbox { public static void main(String[] args) { Thread t1

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.