Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

newbie question



I recently started using Objective-c/cocoa/xcode. I'm trying to parse a srt (subtitle) file.
The input file contains a string: 00:37:58,112 --> 00:38:01,324

I want to convert the time-index (string) to seconds (float): 37*60+58,112 = 2278.112

I am using the following code:

NSString * sTime, * eTime;
float sTimeFloat, eTimeFloat;

// Get file contents as a String
NSString * esTime = [ NSString stringWithContentsOfFile:filename]; 

// Create array with components
NSArray * time = [ esTime componentsSeparatedByString:@" --> " ];

// Time index 1
sTime = [ time objectAtIndex:0];

// Time index 2
eTime = [ time lastObject];

// Get seconds, float, Time index 1
sTimeFloat = [[sTime subStringWithRange:NSMakeRange(6,2)] floatValue];

When I compile this code I get the warning:
warning: 'NSString' may  not respond to '-subStringWithRange:'

I understand that there might be some variable type problem, but I cannot find out how to solve this? I ran into comparable problem multiple times before.

Any help would be appreciated!

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/objc-language/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.