set the text of a UILabel to a random object in an array - nsmutablearray

I am trying to make an xcode project that when the user hits a UIButton (IBAction) it sets the text of a UILabel to a random object in an NSMutable Array. I do not want to use case and switches as it takes to long for my situation.
Thanks for your time.

you assign the string to save the array and then on click you generate random number (max value is array size) and then assign to label i think it work

Related

Modify Lee Mac's Length and Area Field to automatically copy the outputted length to clipboad

I'm using Lee Mac's length and area field to automatically get the total length of an object.
I'm a complete beginner on AutoLisp so I cant find the variable responsible on holding the total length so I can put it in my snippet code to automatically copy it on my clipboard for easy pasting on excel.
Here's my code snippet for automatically putting it to clipboard
(vlax-invoke
(vlax-get (vlax-get (vlax-create-object "htmlfile") 'ParentWindow) 'ClipBoardData)
'setData
"TEXT"
(getvar
)
Since my application uses AutoCAD field expressions to output the length and/or area, the length & area values are not stored in any variable in the code; furthermore, the resulting values displayed by the selected annotation object (which may also be converted to other units and formatted by the field expression) are only available after the field expression has been evaluated.
Given the above, you would need to obtain the text content of the object selected for output after it has been populated with the field expression, before copying such content to the Windows clipboard.
This would involve modifying every branch of my LM:outputtext function to assign the result of evaluating the field expression to a variable which may then be returned by the function and used by the calling function.

ListBox Multi-Value String to Object

I have a ListBox where I need to restrict the number of options selected to two. I'm using 8.5.2 so cannot use the SSJS custom validator, but I can use a Java validator. The Java validator received the submittedValue as a comma-separated String.
The problem occurs if a value contains a comma. In that case, if I split the submittedValue String on commas, my code will think more options have been selected than actually have been.
When the value is written back into the underlying Notes Document, the conversion to getValue() has correctly mapped values. So if getSubmittedValue() was a single option from the ListBox that contained a comma, getValue() gives me a single element rather than two elements.
My query is how to reproduce the getSubmittedValue() to getValue() conversion, to correctly work out how many options have been selected.
Paul, you actually can control the commas. The option has a display string and a value. You could substitute the comma for e.g. # and later before saving it back check if you have a # at the same position the display values have a , and save it then.
It's a lot more work - so not smart.
The other option: take the possible values out one by one:
sort them by size, longest first (this way you avoid having a value that is contained in another value to screw up (e.g. "Red boat" vs "boat"
take them out of the return string (if removal worked, then you have one, stop when you hit the 3rd)
.... but probably the easiest on is to do that in a little client side JavaScript counting the checked=checked values

Adding individual float values per UITableViewCell to get grand totals?

I am having a major problem even getting started with finding an answer to this question? I have a UITableView that is being populated by user generated content and being persisted to CoreData. All is good. However I can't even find a way in the Apple docs to do the following:
How do I add each dollar value in a cell to get a grand total displayed somewhere to the user? In this case it can be thrown in a UILabel in the footer of each section I don't care. What I can't figure out is how to get to each individual cell get the dollar amount entered there and add it to the next dollar amount in the next cell in the section and so on.
Any ideas on how to add totals from cells to get a grand total?
The most elegant solution to this problem is using key paths.
You do not go to the cells and get the data out. You go to your data model and calculate it from there. Remember, MVC dictates that you should always separate model and view.
Suppose you have a subclass of NSManagedObject with an NSNumber attribute "amount" fetched via core data. You can then easily do simple calculations like this:
float sum = [[fetchedObjects valueForKeyPath:#"#sum.amount"] floatValue];
This is described in the Key-Value Coding Programming Guide under Collection Operators.

UILabel string truncate

I have a problem, is there any way to truncate the text of a label without changing its' font-size?
Let's suppose a width of label is 200 and string size is more then 200, it will then squeeze the string and make it size to small to read.
I'm looking for a way to adjust the string length to 200 and truncate rest.
If you do not want the font size to be adjusted in order for the text to fit into the width of the label, you can set the adjustsFontSizeToFitWidth property of the label to NO.
See the UILabel class reference for more information. You will also want to read about the numberOfLines and lineBreakMode properties, as they also affect how truncation of the text in a UILabel works.

force breaking a string in a fixed width Gridview cell

I have a Gridview control on an ASP.Net page with fixed width cells. The data coming from the database occasionally comes over as a contiguous string of characters. When there are dashes in the string, it will break so as not to upset the width of the layout. If there are no dashes (specifically, I'm dealing with underscores), the string will not break and forces the cell to widen out, thus upsetting the layout of the page. Is there a way to tell the cell to keep its width and break the string? As it stands, I don't have access to the field's data directly, as the GridView bind its datasource to a dataset object coming from the database. Thanks for any feedback.
If you handle the RowDataBound event you'll be able to break the string "manually". Otherwise it'll only break based on "HTML rules".
First thing to note is that this doesn't have a lot to do with ASP.NET but is rather a pure HTML (and CSS) problem.
A possible solution is to use the css attribute table-layout: fixed and set some fixed width values to all columns. The disadvantage of this approach is that the total table width is fixed so it doesn't scale with the window size.
Another possible approach is to display in columns shorter strings using a utility function that cuts the long strings to a maximum length.

Resources