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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:47:36+00:00 2026-05-29T22:47:36+00:00

I come from a Visual Basic background (a long time ago), so be gentle

  • 0

I come from a Visual Basic background (a long time ago), so be gentle please…

I’m working on an app for the iPhone, and need to send an NSString (I believe it’s an NSString to a function that is going to convert the NSString to an integer and return the value. The value should probably be returned as an integer as the Core Data attribute is an integer.

I need to display the time of a song in a UILabel, and it’s an NSSTring. I’m storing the data in the Core Data attribute as an integer, as it’s easier to do calculations on it, etc. One of the things I’m doing is converting the seconds (int) into “3:32” NSString for the Label.

cell.profileItemsSongDurationLabel.text= ConvertSecondstoMMSS([[managedObject valueForKey:@"profileItemsSongDurationInSeconds"] description]);
// implicit declaration of function 'ConvertSecondstoMMSS' is invalid in C99 
// Implicit conversion of 'int' to 'NSString *' is disallowed with ARC
// Incompatible integer to pointer conversion passing 'int' to parameter of type 'NSString *'


- (NSString *)ConvertSecondstoMMSS:(NSString *)songLength  // Conflicting return type in implementation of 'ConvertSecondstoMMSS:': 'int' vs 'NSString *'
{

NSString *lengthOfSongInmmss;

int songLengthInSeconds = [songLength intValue];

int hours = songLengthInSeconds/ 3600;
int minutes = (songLengthInSeconds % 3600) / 60;
int seconds  = songLengthInSeconds % 60;

return lengthOfSongInmmss = [NSString stringWithFormat:@"%d:%02d:%02d", hours, minutes, seconds];
}

Naturally this code has some issues, but I would appreciate a quick lesson on what’s wrong, and how to fix it.

Thanks in advance

-Paul

Revised solution:

int convertToInt = [[[managedObject valueForKey:@"profileItemsSongDurationInSeconds"] description] intValue];
NSLog(@"convertToInt: %d", convertToInt);
cell.profileItemsSongDurationLabel.text = [self convertSecondstoMMSS:convertToInt];


- (NSString *)convertSecondstoMMSS:(int)songLength
{
    NSString *lengthOfSongInmmss;

    int hours   = songLength/ 3600;
    int minutes = (songLength % 3600) / 60;
    int seconds = songLength % 60;

    return lengthOfSongInmmss = [NSString stringWithFormat:@"%d:%02d:%02d", hours, minutes, seconds];
}

The only remaining item to resolve is the case of the lengthOfSongInmmss. Rarely will I have a song with a duration of an hour, it’s only there for the “just in case” Is there a way to not have the hour shown via the string format, or it it better to do a simple “if” statement?

Thanks again!

  • 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-29T22:47:38+00:00Added an answer on May 29, 2026 at 10:47 pm

    To address the errors:

    Since the NSManagedObject is returning an integer, do this:

    cell.profileItemsSongDurationLabel.text = [self ConvertSecondstoMMSS:[managedObject valueForKey:@"profileItemsSongDurationInSeconds"]];
    

    Then change the method declaration to expect an integer as in:

    -(NSString *)ConvertSecondstoMMSS:(int)songLength
    

    And use the integer directly within the method like this:

    int hours = songLength / 3600;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come to Java from Visual Basic, and seem to think I have
I come from a windows w/ visual-studio background for native development and I am
I'm in Eclipse writing Java. I come from Visual Studio with Resharper writing C#.
I come from a Java background, where packages are used, not namespaces. I'm used
I come from a mainly PHP background and make good use of the Apache
I come from a CVS background. I'm currently investigating using SVN for a project.
I come from a background of MoM. I think I understand ESB conceptually. However,
I come from more of a Java background. In the last year or two,
I come from Windows world and used Visual Studio for years. When I click
I come from a .NET background and will be going into the field of

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.