Показ дописів із міткою SDK. Показати всі дописи
Показ дописів із міткою SDK. Показати всі дописи

пʼятниця, 20 травня 2011 р.

CGAffineTransformInvert - singular matrix error

Being inaccurate with affine transformations (and in some other cases) you can easily get a kind of this CoreGraphics error:

<Error>: CGAffineTransformInvert: singular matrix.

There are at least two possibilities why you get this:

A) Probably you tried to use singular transformation matrix somewhere in your code. You should check your transformation matrices and avoid matrices like:
0 0 0
0 0 0
0 0 1
and others - check out Google how to tell singular 3x3 matrix (hint: it has determinant = 0).

B) What can be worse - you don't have a clue about affine transformations and matrices and have never used them in your code but still get this error. One reason I have found is scaling you UIScrollView instance to 0 scale using either setZoomScale:animated: method or zoomScale property. Check your scroll views.

четвер, 14 квітня 2011 р.

Sorting NSArray with blocks

iOS4 blocks introduced a new way to sort NSArray. There is no need to provide selectors or functions as comparators any more. All you need is to provide a comparator block which returns one of 3 NSComparator values and take to objects as an argument. The input and output is same as for the outdated selector/function way (you can hardly change general comparator interface) but now your comparator block captures you function context! Additionally all the code is in the same place.

Below is a bit of my recent work code that changes the order of sorting based on the class instance variable m_seatQuality value:

featuresArray = [[unsortedFeaturesArray sortedArrayUsingComparator: ^(id a, id b) {

DMSeatFeature *first = ( DMSeatFeature* ) a;

DMSeatFeature *second = ( DMSeatFeature* ) b;

if ( first.quality == second.quality )

return NSOrderedSame;

else

{

if ( eSeatQualityGreen == m_seatQuality

|| eSeatQualityYellowGreen == m_seatQuality

|| eSeatQualityDefault == m_seatQuality )

{

if ( first.quality < second.quality )

return NSOrderedAscending;

else

return NSOrderedDescending;

}

else // eSeatQualityRed || eSeatQualityYellow

{

if ( first.quality > second.quality )

return NSOrderedAscending;

else

return NSOrderedDescending;

}

}

}] retain];

пʼятниця, 8 квітня 2011 р.

WARNING! Creating precompiled collator because collator is out of date. This is expensive!

Today I've found a nice iOS warning every second time I start up my application on the device: "WARNING! Creating precompiled collator because collator is out of date. This is expensive!". Apple's programmers are informative about the consequences but not that much about the causes. I don't get any other errors or warning.


Google also can hardly help to comprehend what's happening. There are only some anecdotal evidences that it happens on iOS 4.2.1 - same as my device is running. Some other sources suggest that the warning is due to framework bug and I will get rid of it tomorrow after iOS 4.3 installation (or iPhone SDK 4.3 setup).