Previous Index Next

BridgePlus.framework, SMSForder Class Methods

Category

List manipulation methods

Method

colsToRowsIn:error:

Summary

Works on a list of lists, each containing the same number of entries. The result will also be a list of lists, where the first list will consist of the first item of each of the original lists, and so on. Calling it a second time effectively returns the list to its original value

Signature

+ (NSArray *)colsToRowsIn:(NSArray *)listOrArray error:(NSError *__autoreleasing *)outError

Parameters

listOrArray = an array or list of sublists, all of which must contain the same number of items

outError = missing value or reference

Result

An array of arrays

Availability

Version 1.0.0

Notes

If you set outError to reference, the result will be a list of two items. If there is no error, the first item will be the result of the method and the second will be missing value. If there is an error, the first item will be missing value and the second item with be an NSError.

Sample

use scripting additions

use framework "Foundation"

use script "BridgePlus"

load framework


set theLists to {{1.1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

set theResult to current application's SMSForder's colsToRowsIn:theLists |error|:(missing value)

ASify from theResult

--> {{1.1, 4, 7}, {2, 5, 8}, {3, 6, 9}}

theResult as list -- 10.11 only

--> {{1.1, 4, 7}, {2, 5, 8}, {3, 6, 9}}

theResult as list -- 10.9 and 10.10

--> {{1.100000023842, 4, 7}, {2, 5, 8}, {3, 6, 9}}


set theLists to {{1, 2, 3}, {4, 5}, {7, 8, 9}}

set {theResult, theError} to current application's SMSForder's colsToRowsIn:theLists |error|:(reference)

if theResult = missing value then error (theError's localizedDescription() as text)

--> error number -2700  Can't perform cols to rows when lists have differing item counts.


Click here to open script in a script editor