473,473 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Add user input into UITableView in Xcode

3 New Member
I want to get tableView value from the user.
I used UITextField for get value from user.
Please give me Source code for this.
Thank You.
Feb 14 '12 #1
1 9081
shyamenk
2 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2. - (NSString *)relativeDateString
  3. {
  4.     const int SECOND = 1;
  5.     const int MINUTE = 60 * SECOND;
  6.     const int HOUR = 60 * MINUTE;
  7.     const int DAY = 24 * HOUR;
  8.     const int MONTH = 30 * DAY;
  9.  
  10.     NSDate *now = [NSDate date];
  11.     NSTimeInterval delta = [self timeIntervalSinceDate:now] * -1.0;
  12.  
  13.     NSCalendar *calendar = [NSCalendar currentCalendar];
  14.     NSUInteger units = (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit);
  15.     NSDateComponents *components = [calendar components:units fromDate:self toDate:now options:0];
  16.  
  17.     NSString *relativeString;
  18.  
  19.     if (delta < 0) {
  20.         relativeString = @"!n the future!";
  21.  
  22.     } else if (delta < 1 * MINUTE) {
  23.         relativeString = (components.second == 1) ? @"One second ago" : [NSString stringWithFormat:@"%d seconds ago",components.second];
  24.  
  25.     } else if (delta < 2 * MINUTE) {
  26.         relativeString =  @"a minute ago";
  27.  
  28.     } else if (delta < 45 * MINUTE) {
  29.         relativeString = [NSString stringWithFormat:@"%d minutes ago",components.minute];
  30.  
  31.     } else if (delta < 90 * MINUTE) {
  32.         relativeString = @"an hour ago";
  33.  
  34.     } else if (delta < 24 * HOUR) {
  35.         relativeString = [NSString stringWithFormat:@"%d hours ago",components.hour];
  36.  
  37.     } else if (delta < 48 * HOUR) {
  38.         relativeString = @"yesterday";
  39.  
  40.     } else if (delta < 30 * DAY) {
  41.         relativeString = [NSString stringWithFormat:@"%d days ago",components.day];
  42.  
  43.     } else if (delta < 12 * MONTH) {
  44.         relativeString = (components.month <= 1) ? @"one month ago" : [NSString stringWithFormat:@"%d months ago",components.month];
  45.  
  46.     } else {
  47.         relativeString = (components.year <= 1) ? @"one year ago" : [NSString stringWithFormat:@"%d years ago",components.year];
  48.  
  49.     }
  50.  
  51.     return relativeString;
  52. }
  53.  
  54.  
  55.  
Mar 16 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: hokiegal99 | last post by:
I don't understand how to use a loop to keep track of user input. Could someone show me how to do what the program below does with a loop? Thnaks! ---------------------------- #Write a...
3
by: N?ant Humain | last post by:
I have just begun learning Python so that I can write a simple script to make modification of a file used by another Python script easier. This file is basically a list of regular expressions. What...
0
by: Michael | last post by:
Hi All, I am working on my intranet reporting web site, by use of IIS5 + Office2000 +SQL2000. Currently, the first step, I show user an ASP web-interface to collect user input, keyword...
17
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php"...
3
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the...
2
by: danielboendergaard | last post by:
Hey Im making a homepage in php. I use a html form to put data into mysql and i want to make some buttons which inserts user input values into a textarea. I have used a button like this: <input...
9
by: chuck | last post by:
I need some help with validating user input. I am writing a C computer program for an intro to C course. Here is the situation. I am creating an application that will do currency conversions. ...
2
by: Matt | last post by:
Hi, I'm ridiculously new to Access (about a week!) so please be patient! My database is a record of British Standards. Each has a unique identifier. Some are split into parts. I would like...
2
by: Andy | last post by:
Hi guys, I'm writing a program with a feature of accepting user input as command text and parsing it to correct function calls...example: "5 minutes later"/"5 min later"/"5 minute...
12
by: Tarique | last post by:
I have tried to restrict the no. of columns in a line oriented user input.Can anyone please point out potential flaws in this method? btw.. 1.I have not used dynamic memory allocation because...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.