Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/5 #6

Merged
merged 2 commits into from
Feb 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions MagicPie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@
BD0CFE8717F94CC60038FBC1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand All @@ -547,7 +546,6 @@
BD0CFE8817F94CC60038FBC1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand All @@ -565,7 +563,6 @@
BD0CFE8A17F94CC60038FBC1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/MagicPie.app/MagicPie";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
Expand All @@ -588,7 +585,6 @@
BD0CFE8B17F94CC60038FBC1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/MagicPie.app/MagicPie";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
Expand Down
2 changes: 1 addition & 1 deletion MagicPie/Example1Controller.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (IBAction)deletePressed:(id)sender
- (IBAction)animateChangeVal:(id)sender
{
if(self.pieView.layer.values.count == 0)return;
int randCount = MAX(MIN(self.pieView.layer.values.count, 2), arc4random() % self.pieView.layer.values.count);
NSUInteger randCount = MAX(MIN(self.pieView.layer.values.count, 2), arc4random() % self.pieView.layer.values.count);
NSMutableArray* randIndexes = [NSMutableArray new];
NSMutableArray* changeValArr = [NSMutableArray new];
[PieElement animateChanges:^{
Expand Down
2 changes: 1 addition & 1 deletion MagicPie/Example3PieLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ - (void)drawElement:(PieElement *)elem context:(CGContextRef)ctx
float endRadius = MIN(self.bounds.size.width / 2.0, self.bounds.size.height / 2.0);
float startRadius = self.minRadius;

int lvlCount = self.colorsArr.count;
NSUInteger lvlCount = self.colorsArr.count;
float levelWidth = (endRadius - startRadius - (lvlCount-1)*indent) / lvlCount;
float currRadius = startRadius;

Expand Down
14 changes: 7 additions & 7 deletions MagicPie/TestPieLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ + (void)testsOnPieLayer:(PieLayer*)pieLayer testCount:(int)count eachActionBlock
+ (void)timerAction:(NSTimer*)timer
{
NSMutableString* timerCountStr = timer.userInfo[@"count"];
int count = [timerCountStr integerValue];
NSUInteger count = [timerCountStr integerValue];
if(count <= 0){
[timer invalidate];
return;
} else {
count--;
[timerCountStr setString:[NSString stringWithFormat:@"%d", count]];
[timerCountStr setString:[NSString stringWithFormat:@"%lu", count]];
}

void(^actionBlock)(NSString* actionDesc) = timer.userInfo[@"actionBlock"];
PieLayer* pieLayer = timer.userInfo[@"pieLayer"];
if(actionBlock){
int valuesCount = pieLayer.values.count;
NSUInteger valuesCount = pieLayer.values.count;
NSString* actionDesc = [self runRandomActionWithPie:pieLayer];
if(actionDesc){
actionDesc = [NSString stringWithFormat:@"Curr values count %d. %@", valuesCount, actionDesc];
actionDesc = [NSString stringWithFormat:@"Curr values count %lu. %@", valuesCount, actionDesc];
actionBlock(actionDesc);
}
}else
Expand All @@ -62,13 +62,13 @@ + (NSString*)runRandomActionWithPie:(PieLayer*)pieLayer
return nil;

[pieLayer addValues:arr animated:YES];
return [NSString stringWithFormat:@"Add %d elements", arr.count];
return [NSString stringWithFormat:@"Add %lu elements", arr.count];
} else if(action == PieActionInsert){
NSArray* arr = [self randArr];
if(arr.count == 0)
return nil;

int count = pieLayer.values.count;
NSUInteger count = pieLayer.values.count;
NSMutableArray* indxArr = [NSMutableArray array];
for(int i = 0; i < arr.count; i++){
int indx = arc4random() % (count+1);
Expand All @@ -77,7 +77,7 @@ + (NSString*)runRandomActionWithPie:(PieLayer*)pieLayer
count++;
}
[pieLayer insertValues:arr atIndexes:indxArr animated:YES];
return [NSString stringWithFormat:@"Insert %d elements at indexes: %@", arr.count, [self arrDesc:indxArr]];
return [NSString stringWithFormat:@"Insert %lu elements at indexes: %@", arr.count, [self arrDesc:indxArr]];
} else if(action == PieActionDelete) {
if(pieLayer.values.count == 0)
return nil;
Expand Down
14 changes: 7 additions & 7 deletions MagicPieLayer/NSMutableArray+pieEx.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ - (void)sortWithIndexes:(NSArray*)indexes

- (void)insertSortedObjects:(NSArray*)objects indexes:(NSArray*)indexes
{
int decrementIdx = 0;
for(int i = 0; i < indexes.count; i++){
NSInteger decrementIdx = 0;
for(NSInteger i = 0; i < indexes.count; i++){
//after each insert, each next index must be displaced
int insertIdx = [indexes[i] integerValue] - decrementIdx;
NSInteger insertIdx = [indexes[i] integerValue] - decrementIdx;
if(insertIdx < self.count)
decrementIdx++;
[self insertObject:objects[i] atIndex:insertIdx];
Expand All @@ -66,11 +66,11 @@ - (void)insertObjects:(NSArray*)objects indexes:(NSArray*)indexes
- (void)updateIndexesWithUnusedIndexes:(NSArray*)unusedIndexes
{
unusedIndexes = [unusedIndexes sortedArrayUsingSelector:@selector(compare:)];
int indexesCount = self.count;
NSInteger indexesCount = self.count;
for(NSNumber* unusedIdxNum in unusedIndexes){
int unusedIdx = unusedIdxNum.integerValue;
for(int i = 0; i < indexesCount; i++){
int idx = [self[i] integerValue];
NSInteger unusedIdx = unusedIdxNum.integerValue;
for(NSInteger i = 0; i < indexesCount; i++){
NSInteger idx = [self[i] integerValue];
if(idx >= unusedIdx)
self[i] = @(idx+1);
}
Expand Down
12 changes: 6 additions & 6 deletions MagicPieLayer/PieLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ - (void)setup
#pragma mark - Adding, inserting and deleting
- (void)addValues:(NSArray *)addingNewValues animated:(BOOL)animated
{
int count = addingNewValues.count;
int currCount = self.values.count;
NSInteger count = addingNewValues.count;
NSInteger currCount = self.values.count;
NSMutableArray* indexes = [NSMutableArray arrayWithCapacity:addingNewValues.count];
for(int i = 0; i < count; i++){
for(NSInteger i = 0; i < count; i++){
[indexes addObject:@(i+currCount)];
}
[self insertValues:addingNewValues atIndexes:indexes animated:animated];
Expand All @@ -130,7 +130,7 @@ - (BOOL)performDelayedAnimation
animationBeginState = [[NSMutableArray alloc] initWithArray:currentValues copyItems:YES];
animationEndState = [NSMutableArray arrayWithArray:self.values];
for(NSNumber* delIdxNum in animationDeletingIndexes){
int delIdx = delIdxNum.integerValue;
NSInteger delIdx = delIdxNum.integerValue;
PieElement* elem = [currentValues[delIdx] copy];
[elem setVal_:0.0];
elem.titleAlpha = 0.0;
Expand All @@ -143,7 +143,7 @@ - (BOOL)performDelayedAnimation

- (void)insertValues:(NSArray *)array atIndexes:(NSArray *)indexes animated:(BOOL)animated
{
NSAssert2(array.count == indexes.count, @"Array sizes must be equal: values.count = %d; indexes.count = %d;", array.count, indexes.count);
NSAssert2(array.count == indexes.count, @"Array sizes must be equal: values.count = %d; indexes.count = %d;", (int)array.count, (int)indexes.count);
for(PieElement* elem in array){
[elem addedToPieLayer:self];
}
Expand Down Expand Up @@ -232,7 +232,7 @@ - (void)delayedAnimateChanges

- (void)animateFromValues:(NSArray*)fromValues toValues:(NSArray*)toValues timingFunction:(NSString*)timingFunction
{
NSAssert2(fromValues.count == toValues.count, @"Array sizes must be equal: fromValues.count = %d; toValues.count = %d;", fromValues.count, toValues.count);
NSAssert2(fromValues.count == toValues.count, @"Array sizes must be equal: fromValues.count = %d; toValues.count = %d;", (int)fromValues.count, (int)toValues.count);
float fromSum = [[fromValues valueForKeyPath:@"@sum.val"] floatValue];
float toSum = [[toValues valueForKeyPath:@"@sum.val"] floatValue];
if(fromSum <= 0 || toSum <= 0){
Expand Down