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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:35:44+00:00 2026-05-28T03:35:44+00:00

I have created a custom class which show time date formatter and I need

  • 0

I have created a custom class which show time date formatter and I need a timer like method to update the seconds, so here is my code :

CustomClass.m

- (NSString *) showLocaleTime {

            NSDateFormatter *timeFormater = [[NSDateFormatter alloc] init];
timeFormater = [setDateFormat:@"HH:mm:ss "];

NSString *currDay = [timeFormater stringFromDate:[NSDate date]];
currDay = [NSString stringWithFormat:@"%@",currDay];
[timeFormater release];


    return timer;
}


- (void) updateLocaleTime {

    [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(showLocaleTime) userInfo:nil repeats:YES];

}

viewController.m :

CustomClass *time = [[CustomClass alloc]init];
label.text = [time showLocaleTime];

[time updateLocaleTime];

But the problem is the updateLocaleTime does not call to update seconds ! am I missing something ?
Thanks

  • 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-28T03:35:45+00:00Added an answer on May 28, 2026 at 3:35 am

    Instead of calling updateLocaleTime in CustomClass, just start the timer in the view controller itself.

    [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateLocaleTime) userInfo:nil repeats:YES];
    

    Add updateLocaleTime method to the viewController

    - (void) updateLocaleTime {
    
       CustomClass *time = [[CustomClass alloc]init];
       label.text = [time showLocaleTime];
       [time release];
    }
    

    But here we are allocating and releasing the CustomClass again and again for every 0.5 seconds. Instead you declare it as class member, in .h file and allocate that in viewDidLoad.

    So no need to allocate in updateLocaleTime method. Also release that time in viewDidUnload method.

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

Sidebar

Related Questions

I have created a custom class for my dates and need move dates forward
I just need to override the show() method for the Toast class. I created
I have created my custom MembershipProvider. I have used an instance of the class
If have created a custom role within SqlServer which I added to the db__denydatareader
I have created a custom list as a feature in sharepoint. i need to
I have created a custom ExpandableListAdapter and everything works properly. What I'd like to
I have 2 Lists containing entries of a custom class I have created. Basically,
I created a custom password box user control which is able to show and
I have a custom thread pool class, that creates some threads that each wait
I have created custom MembershipUser, MembershipProvider and RolePrivoder classes. These all work and I

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.