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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:51:30+00:00 2026-05-21T16:51:30+00:00

I’m trying to create a class that represents hours of operation in an Obj-C

  • 0

I’m trying to create a class that represents hours of operation in an Obj-C program. I have been considering using NSDatesComponent to do this, but I feel there should be an easier way. Does anyone have any tips as to how to do this?

In Core Data, I would have a shop entity that would have an ivar that is an array. This array would have seven entries for each day of the week, and the value for each day would be an hoursOp object that would represent a range of hours. 9-5, 10-6, etc. The issue is, I’m not sure how to create my hoursOp class to represent a range of hours. I was thinking of using NSDateComponents, but am unsure if I should bother. Currently, I think that an hoursOp object should hold two variables: a starting time and an ending time.

Furthermore, this is complicated by the possible need for multiple hoursOp objects in an array entry- what if a shop has operating hours of 10-4, then 6-8? So instead of an array that holds hoursOp object, it would be a two-dimensional array where each entry is an array of its own holding 1 or more hoursOp objects. This is all a bit convoluted, but I believe I could get it to work, once I figure out how to represent the hours (or the ranges themselves, if anyone has a better suggestion).

  • 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-21T16:51:31+00:00Added an answer on May 21, 2026 at 4:51 pm

    This is what I ended up doing, using NSDate and NSDateFormatter only, where open is an NSString formatted in military time.

    -(void) setOpeningTimeWithString: (NSString *)open
    {
        NSDateFormatter * formatFromInput = [[NSDateFormatter alloc] init];
        [formatFromInput setDateFormat:@"HH:mm"];
        self.openingTime = [formatFromInput dateFromString:open];   
        [formatFromInput release];  
    }
    

    The takeaway lesson is that it’s perfectly okay to have NSDate objects where you only set the hourly components- everything else is only set to January 1, 1970, and it doesn’t cause any issues.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and

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.