Now basically I was there to be a fixed number of spaces for each string that is entered into cellID. If i'm not mistaken, in c programming you would do something like %8@ to have 8 spaces set for the string. How would you do this in xcode?
Objective-C is a strict superset of the c programming language so c functions should work just fine (you may just have to convert from c-string eventually)
__________________
I'm starting a new blog dedicated to iOS development. Check it out at:
Objective-C is a strict superset of the c programming language so c functions should work just fine (you may just have to convert from c-string eventually)
Thanks for the reply! I've tried the method that I mentioned above but no luck. Do you know the proper terminology or what the code would be to achieve what I am trying to do?
The number-based system that you described only worked (and still works) for numerical values, not strings. For simple spacing, use the \t escape sequence. Most likely though, there will be a better option for spacing—what are you trying to do?
Note that iOS's default font is not monospace—that is, spaces are not guaranteed to make things line up, unlike in the Console.
__________________
If I have helped you, please consider donating. I use PayPal. It would mean a lot to me!
Thanks for the reply! I've tried the method that I mentioned above but no luck. Do you know the proper terminology or what the code would be to achieve what I am trying to do?
As the other poster says, Objective C is a true superset of C.
You can use C libraries and C strings, and then copy the results to an objective C string object. You should use pure C library functions if you want the exact same behavior, not NSString formatted string methods.
Also as the other poster says, the field size you're talking about is for numbers, and I'm pretty sure it doesn't work for strings.
Note that it would be trivial to create a method padToSize that would take an NSString as input and return a string padded to a specified length:
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Thanks for the responses everyone. Basically what I'm trying to do is I have a tableView and I'm looking to line up all of the data that is inputted. I'm not sure if I have to make columns in the table or how I would do this.
For example:
Code:
Test 78% 2/3
Assignment 5% 6/10
Exam 10% 9/20
That's how i'm trying to organize my cells. Any idea?
Thanks for the responses everyone. Basically what I'm trying to do is I have a tableView and I'm looking to line up all of the data that is inputted. I'm not sure if I have to make columns in the table or how I would do this.
For example:
Code:
Test 78% 2/3
Assignment 5% 6/10
Exam 10% 9/20
That's how i'm trying to organize my cells. Any idea?
This is an issue I'm pondering myself. I think what you'll want to do is make custom cells, with three labels: one on the left, left-justified, for the category; one in the middle, right-justified, for the percentage; and one on the right, (can you do justification on a character in a UILabel? if not, then just right-justified), for the fraction. Others feel free to chip in with better ideas and/or the code to implement that one.
Yes, a custom cell would be the only (or at least the most feasible, by far) way to go. Yes, you can set the justification in a label—it's an option under the first inspector in IB. Check out the Customizing Cells page at ADC.
__________________
If I have helped you, please consider donating. I use PayPal. It would mean a lot to me!