this one helps. First of all I want to say that you should try to learn Objective-C on a better level. It is not too hard (esp. coming from Python, because both languages are dynamically typed). However, I will give you some advises to your Q.
Let's have a closer view to your code:
NSArray *timouts = [NSArray arrayWithObjects:[NSString stringWithFormat:@"10000"],[NSString stringWithFormat:@"10000"],[NSString stringWithFormat:@"10000"],[NSString stringWithFormat:@"10"],nil];
NSArray *timeOuts = @[@10000, @10000, @10000, @10];
NSLog( @"%@", timeOuts );
NSMutableArray * bytes = [NSMutableArray arrayWithCapacity:4];
for (NSNumber *value in timeOuts) // Take out numbers
{
…
}
NSMutableArray *bytes = [NSMutableArray arrayWithCapacity:4];
for (NSNumber *value in timeOuts) // Take out numbers
{
int intValue = [value intValue];
…
}
NSMutableArray *bytes = [NSMutableArray arrayWithCapacity:4];
for (NSNumber *value in timeOuts) // Take out numbers
{
int intValue = [value intValue];
for( int x = 0; x < 4; x++ )
{
int byte = intValue & 0xFF000000; // Mask out bit 0-23
[bytes addObject:@(byte)]; // Store byte
intValue <<= 8; // Shift up bit 0-23 to 8-31 for the next iteration
}
}
NSLog( @"%@", bytes );
NSArray *timeOuts = @[@10000, @10000, @10000, @10];
NSLog( @"%@", timeOuts );
NSMutableArray *bytes = [NSMutableArray arrayWithCapacity:4];
for (NSNumber *value in timeOuts) // Take out numbers
{
int intValue = [value intValue];
for( int x = 0; x < 4; x++ )
{
int byte = intValue & 0xFF; // Mask out bit 8-31
[bytes addObject:@(byte)]; // Store byte
intValue >>= 8; // Shift down bit 8-31 to 0-23 for the next iteration
}
}
NSLog( @"%@", bytes );