How to remove an object from other keys in a dictionary [Objective-C]? - ios

I have an NSMutableDictionary as follows:
{ 0 = (1,5,6); 1 = (0,2,6,7); 2 = (1,7,8); 5 = (0,6,10,11); 6 =
(0,1,5,7,11,12)};
in the format of {NSNumber:NSMutableArray}
I want to remove every 0 that is there in every key or the keys for the values of '0'. What is a way to do it?
The expected outcome is:
{ 0 = (1,5,6); 1 = (2,6,7); 2 = (1,7,8); 5 = (6,10,11); 6 =
(1,5,7,11,12)};
I am looking for an elegant solution.

Use this assuming that your NSMutableArray is an NSNumber array, also the key 0 is removed in this improvement
Improved
NSMutableDictionary * dict = [NSMutableDictionary dictionary];
dict[#0] = [NSMutableArray arrayWithObjects:#0,#10, nil];
dict[#1] = [NSMutableArray arrayWithObjects:#0,#10, nil];
dict[#2] = [NSMutableArray arrayWithObjects:#0,#7,#10, nil];
int valueToRemove = 0; //change this value for what you need
for (NSNumber * key in dict.allKeys) {
if([key intValue] == valueToRemove) {dict[key] = nil;}
dict[key] = [dict[key] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:#"intValue != %i",valueToRemove]];
}
NSLog(#"%#",dict);
CONSOLE LOG
2017-07-28 02:18:21.257 ArrayProblemQuestion[76557:1576267] {
1 = (
10
);
2 = (
7,
10
); }
if you want to loop only for certain keys then
NSMutableArray * array = [NSMutableArray arrayWithObjects:#1,#3,#0, nil];
for (NSNumber * key in [dict.allKeys filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:#"intValue IN %#",array]]) {
NSLog(#"%#",key);
}
this will loop only for the keys contained in array
Hope this helps

// This is your input
NSMutableDictionary *dicMain = [NSMutableDictionary new];
dicMain[#"0"] = #[#1,#5,#6];
dicMain[#"1"] = #[#0,#2,#6,#7];
dicMain[#"2"] = #[#1,#7,#8];
dicMain[#"5"] = #[#0,#6,#10,#11];
dicMain[#"6"] = #[#0,#1,#5,#7,#11,#12];
NSLog(#"%#",dicMain);
// Remove key from Dic if its having 0
if([[dicMain allKeys] containsObject:#"0"])
[dicMain removeObjectForKey:#"0"];
// Check each and every object into all key's that if its having 0 then it will remove
NSArray *aryAllKeys = [dicMain allKeys];
for(NSString *strKey in aryAllKeys)
{
NSMutableArray *aryNewValue = [NSMutableArray new];
NSArray *aryKeyValues = [dicMain objectForKey:strKey];
for(NSString *str in aryKeyValues)
{
if([str intValue] != 0)
{
[aryNewValue addObject:str];
}
}
// Set New array
[dicMain setObject:aryNewValue forKey:strKey];
}
NSLog(#"%#",dicMain);
The output of main Dic without removing 0:
{
1 = (
2,
6,
7
);
2 = (
1,
7,
8
);
5 = (
0,
6,
10,
11
);
6 = (
0,
1,
5,
7,
11,
12
);
}
After Removing 0:
{
1 = (
2,
6,
7
);
2 = (
1,
7,
8
);
5 = (
6,
10,
11
);
6 = (
1,
5,
7,
11,
12
);
}

I'd do something like this..
[myDict enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull key,
NSMutableArray * _Nonnull array,
BOOL * _Nonnull stop) {
[array removeObject:#0];
}];

You can do like below. This is improvement of other answer with key '0'.
NSMutableDictionary *dict = [NSMutableDictionary new];
dict[#"0"] = #[#1,#5,#6];
dict[#"1"] = #[#0,#2,#6,#7];
dict[#"2"] = #[#1,#7,#8];
dict[#"5"] = #[#6,#10,#11];
dict[#"6"] = #[#0,#1,#5,#7,#11,#12];
int valueToRemove = 0; //change this value for what you need to remove
for (NSNumber * key in dict.allKeys) {
if([key intValue] == valueToRemove) {
dict[key] = [dict[key] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:#"intValue != %i",valueToRemove]];
}else{
dict[key] = [dict[key] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:#"intValue != %i",valueToRemove]];
}
}
NSLog(#"%#",dict);
And your expected output like this with key '0'.
{
0 = ( 1, 5, 6 );
1 = ( 2, 6, 7 );
2 = ( 1, 7, 8 );
5 = ( 6, 10, 11 );
6 = ( 1, 5, 7, 11, 12 );
}

Related

How to reduce the set of colors in Objective-C

I'm very, very new to Objective-C (this is for a React Native app), and I am trying to pare down a list of colors and remove duplicates.
I've got this so far:
... code related to pulling pixels from an image
float flexibility = 2;
float range = 60;
NSMutableArray * colors = [NSMutableArray new];
float x = 0;
float y = 0;
for (int n = 0; n<(width*height); n++){
int index = (bytesPerRow * y) + x * bytesPerPixel;
int red = rawData[index];
int green = rawData[index + 1];
int blue = rawData[index + 2];
int alpha = rawData[index + 3];
NSArray * a = [NSArray arrayWithObjects:[NSString stringWithFormat:#"%i",red],[NSString stringWithFormat:#"%i",green],[NSString stringWithFormat:#"%i",blue],[NSString stringWithFormat:#"%i",alpha], nil];
[colors addObject:a];
y++;
if (y==height){
y=0;
x++;
}
}
free(rawData);
Now the script I am basing this off of has some code to pare down the list:
NSMutableDictionary * colourCounter = [NSMutableDictionary new];
//count the occurences in the array
NSCountedSet *countedSet = [[NSCountedSet alloc] initWithArray:colors];
for (NSString *item in countedSet) {
NSUInteger count = [countedSet countForObject:item];
[colourCounter setValue:[NSNumber numberWithInteger:count] forKey:item];
}
//sort keys highest occurrence to lowest
NSArray *orderedKeys = [colourCounter keysSortedByValueUsingComparator:^NSComparisonResult(id obj1, id obj2){
return [obj2 compare:obj1];
}];
//checks if the colour is similar to another one already included
NSMutableArray * ranges = [NSMutableArray new];
for (NSString * key in orderedKeys){
NSArray * rgb = [key componentsSeparatedByString:#","];
int r = [rgb[0] intValue];
int g = [rgb[1] intValue];
int b = [rgb[2] intValue];
bool exclude = false;
for (NSString * ranged_key in ranges){
NSArray * ranged_rgb = [ranged_key componentsSeparatedByString:#","];
int ranged_r = [ranged_rgb[0] intValue];
int ranged_g = [ranged_rgb[1] intValue];
int ranged_b = [ranged_rgb[2] intValue];
if (r>= ranged_r-range && r<= ranged_r+range){
if (g>= ranged_g-range && g<= ranged_g+range){
if (b>= ranged_b-range && b<= ranged_b+range){
exclude = true;
}
}
}
}
if (!exclude){ [ranges addObject:key]; }
}
//return ranges array here if you just want the ordered colours high to low
NSMutableArray * colourArray = [NSMutableArray new];
for (NSString * key in ranges){
NSArray * rgb = [key componentsSeparatedByString:#","];
float r = [rgb[0] floatValue];
float g = [rgb[1] floatValue];
float b = [rgb[2] floatValue];
UIColor * colour = [UIColor colorWithRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f];
[colourArray addObject:colour];
}
//if you just want an array of images of most common to least, return here
//return [NSDictionary dictionaryWithObject:colourArray forKey:#"colours"];
I ultimately want to return this colourArray (the original library uses colour, I use color, so you'll sometimes see one or the other spelling - I'll probably standardize it to color when finished).
However, whenever I use this code, RN generates an error:
As far as I can tell, this is due to calling a function that doesn't exist? Is there something I am missing here, or calling incorrectly?

Print UIImage metadata to label

I'm attempting to read the metadata produced by a UIImage when shot from the UIImagePicker, and I'm having some trouble.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
// get the metadata
NSDictionary *imageMetadata = [info objectForKey:UIImagePickerControllerMediaMetadata];
NSLog (#"imageMetaData %#",imageMetadata);
This successfully prints the metadata dictionary to NSLog.
The issue I'm having is that I would like to access specific indices of the dictionary (such as FNumber, ISO, etc.) and print them to specific labels, but I can't figure out how to access the individual data.
Here is what I have tried so far to pull the data, but it doesn't seem to find the key (it returns as NULL):
NSLog(#"ISO: %#", imageMetadata[#"ISOSpeedRatings"]);
Based off of what NSLog prints for the dictionary, it seems as if there may be dictionaries within the dictionary, and that's what's throwing me off.
Here's what gets printed for the metadata:
imageMetaData {
DPIHeight = 72;
DPIWidth = 72;
Orientation = 6;
"{Exif}" = {
ApertureValue = "2.27500704749987";
BrightnessValue = "-0.6309286396300304";
ColorSpace = 1;
DateTimeDigitized = "2015:04:01 10:33:37";
DateTimeOriginal = "2015:04:01 10:33:37";
ExposureBiasValue = 0;
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.06666666666666667";
FNumber = "2.2";
Flash = 24;
FocalLenIn35mmFilm = 29;
FocalLength = "4.15";
ISOSpeedRatings = (
320
);
LensMake = Apple;
LensModel = "iPhone 6 back camera 4.15mm f/2.2";
LensSpecification = (
"4.15",
"4.15",
"2.2",
"2.2"
);
MeteringMode = 5;
PixelXDimension = 3264;
PixelYDimension = 2448;
SceneType = 1;
SensingMethod = 2;
ShutterSpeedValue = "3.907056515078773";
SubjectArea = (
1631,
1223,
1795,
1077
);
SubsecTimeDigitized = 705;
SubsecTimeOriginal = 705;
WhiteBalance = 0;
};
"{MakerApple}" = {
1 = 2;
14 = 0;
2 = <0f000b00 06000900 04005000 a900b100 b700bb00 c400cd00 cd00a400 b100c700 14000b00 05000900 06000a00 8a00a800 b000b800 c300cb00 c900cd00 b300a600 2f000700 06000700 0a000400 3500a400 ab00b300 bc00c300 cf00d300 b4007f00 3f000700 09000700 0a000700 05007100 a100af00 b500c200 ce00cd00 a9006b00 1f000a00 0b000900 0a000c00 05001e00 9c00aa00 b400c200 cc00d000 d4005700 2b001900 0d001000 10000d00 08000600 5b00a700 b300bf00 cb00d500 e3008600 eb002800 1a001700 14000c00 0b000700 10009400 b100c000 ce00e000 f400bd00 cf013e00 2a001200 17000f00 0d000800 07004200 b100c000 d300e900 fd000401 ff011101 1d000700 16001400 09000700 07000900 8900bf00 d800ec00 07011f01 10021102 39000b00 10001900 0e000800 0a000700 2c00bf00 dd00f400 0b012401 1e023802 1f010d00 07001900 16000c00 0c000800 21007000 c500f400 0a012e01 10022202 01022500 08001000 18001100 0d001800 1601cc00 d100eb00 09012201 fb011002 26020401 0f000700 16001400 3200e801 6001b000 ce00f400 08011601 e1010602 1a020302 23001700 21002300 84009300 9f00ad00 bf00e800 02011401 ca01fc01 19024002 08013d00 3500ca00 7c009200 9e00ab00 c200d700 f8000a01 b401f101 1b024802 28023000 4a007f00 7f008e00 a000b100 bd00d000 ec00fe00>;
3 = {
epoch = 0;
flags = 1;
timescale = 1000000000;
value = 777291330499583;
};
4 = 1;
5 = 128;
6 = 123;
7 = 1;
8 = (
"0.2226092",
"-0.5721548",
"-0.7796207"
);
9 = 275;
};
"{TIFF}" = {
DateTime = "2015:04:01 10:33:37";
Make = Apple;
Model = "iPhone 6";
Software = "8.1.2";
XResolution = 72;
YResolution = 72;
};
}
Is the data I'm looking for within another NSDictionary named Exif? And if so, how do I access it?
#david strauss can you try this once
- (void) saveImage:(UIImage *)imageToSave withInfo:(NSDictionary *)info{
// Get the assets library
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
// Get the image metadata (EXIF & TIFF)
NSMutableDictionary * imageMetadata = [[info objectForKey:UIImagePickerControllerMediaMetadata] mutableCopy];
// add GPS data
CLLocation * loc = <•••>; // need a location here
if ( loc ) {
[imageMetadata setObject:[self gpsDictionaryForLocation:loc] forKey:(NSString*)kCGImagePropertyGPSDictionary];
}
ALAssetsLibraryWriteImageCompletionBlock imageWriteCompletionBlock =
^(NSURL *newURL, NSError *error) {
if (error) {
NSLog( #"Error writing image with metadata to Photo Library: %#", error );
} else {
NSLog( #"Wrote image %# with metadata %# to Photo Library",newURL,imageMetadata);
}
};
// Save the new image to the Camera Roll
[library writeImageToSavedPhotosAlbum:[imageToSave CGImage]
metadata:imageMetadata
completionBlock:imageWriteCompletionBlock];
[imageMetadata release];
[library release];
}
The metadata dictionary as you've noticed consists of several dictionaries.
So to answer your question - yes, if you're looking for specific values you can access the inner dictionaries. Also, you'd better use the proper keys from ImageIO constants; for example:
NSLog(#"%#", imageMetadata[(NSString*)kCGImagePropertyExifDictionary][(NSString*)kCGImagePropertyExifISOSpeedRatings]);
Or, you can use a key-path:
NSString *keyPath = [NSString stringWithFormat:#"%#.%#",
(NSString*)kCGImagePropertyExifDictionary, (NSString*)kCGImagePropertyExifISOSpeedRatings];
NSLog(#"%#", [imageMetadata valueForKeyPath:keyPath]);
your all required data is within this dictionary only.
you can use json formatter to see the exact location of your data.
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject: imageMetadata
options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
error:&error];
if (! jsonData) {
NSLog(#"Got an error: %#", error);
} else {
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(#"jsonString: %#", jsonString);
}
after this get the exact location of your data from json

How can I compare an NSMutableArray with a c array?

I have an NSMutableArray and I want to test it against multiple "Win" cases.
Meaning, I want to test each 3 integer C array, against the NSMutableArray and see if the ints found in the C array are found in the NSMutablearray
These are my C arrays:
// horizontal
int winCaseHorizontal1[3] = {9, 1, 2};
int winCaseHorizontal2[3] = {3, 4, 5};
int winCaseHorizontal3[3] = {6, 7, 8};
// verticle
int winCaseVerticle1[3] = {9, 3, 6};
int winCaseVerticle2[3] = {1, 4, 7};
int winCaseVerticle3[3] = {2, 5, 8};
// diaganol
int winCaseDiagonal1[3] = {9, 4, 8};
int winCaseDiagonal2[3] = {2, 4, 6};
I want to test the numbers say in the array winCaseHorizontal1, and see if those numbers are found in my NSMutableArray.
I've read about testing if two NSMutableArrays are equal, but this is quite different.
One; this is comparing a c array with an NSMutable,
Two; I don't care if they are equal, I just want to see if the c array ints are found in the NSMutable.
Thanks in advance for the help!
You can loop through your arrays and can find if element exists in NSMutableArray.
-(BOOL)elementFound{
for(NSNumber *number in mutableArray)
{
for(int i = 0; i < sizeof(winCaseHorizontal1) / sizeof(int); i++)
{
if([number integerValue] == winCaseHorizontal1[i]){
return YES;
}
}
for(int i = 0; i < sizeof(winCaseHorizontal2) / sizeof(int); i++)
{
if([number integerValue] == winCaseHorizontal2[i]){
return YES;
}
}
for(int i = 0; i < sizeof(winCaseHorizontal3) / sizeof(int); i++)
{
if([number integerValue] == winCaseHorizontal3[i]){
return YES;
}
}
//other arrays
}
return NO;
}
If you want index or elements which found in your c arrays than you can make another array and add the index or elements in that array and return it at end of function.
EDIT: As BryanChen suggested a faster way to do that is make and NSSet from c array and check if mutableArray element exist of not.
NSMutableSet *winCaseHorizontalSet1 = [[NSMutableSet alloc] init];
for(int i = 0; i < sizeof(winCaseHorizontal1) / sizeof(int); i++)
{
[winCaseHorizontalSet1 addObject:#(winCaseHorizontal1[i])];
}
for(NSNumber *number in mutableArray)
{
BOOL isContain = [winCaseHorizontalSet1 containsObject:number];
if(isContain) return YES;
//other set of c arrays
}

NSMutableArray overwrites the values

perhaps I'm blind but I cant figure out what I am doing wrong.
after the 2 runs (there are only 2 values in the database) I get 2 different values like it should be. Then I write it into the NSMutableArray.
But there is only the 2nd value twice. Shouldnt it add to the end of the array? What do I do wrong?
- (NSMutableArray *)getItemsFromDatabaseWithName:(NSString *)databaseName fromTable:(NSString *)tableName andConstraint:(NSString *)constraint
{
NSString *absolutePath = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:databaseName];
NSLog(#"%#", absolutePath);
//Datenbank öffnen --- "**" bedeuten "&" verwenden
sqlite3_open([absolutePath UTF8String], &_database);
//check if there is a constraint and if not take 2nd statement
if (![constraint isEqualToString:#""])
{
_statement = [NSString stringWithFormat:#"select * from %# where %#",tableName, constraint];
}
else
{
_statement = [NSString stringWithFormat:#"select * from %#",tableName];
}
const char *charStatement = [_statement cStringUsingEncoding:NSUTF8StringEncoding];
sqlite3_stmt *results;
//new array to return values
_mutableItemArray = [NSMutableArray new];
//new ItemModel
ItemModel *tmpItem = [ItemModel new];
if (sqlite3_prepare_v2(_database, charStatement, -1, &results, NULL)== SQLITE_OK)
{
while (sqlite3_step(results) == SQLITE_ROW)
{
_charItemName = (char *)sqlite3_column_text(results, 1);
[tmpItem setItemName:[NSString stringWithUTF8String:_charItemName]];
_charItemDescription = (char *)sqlite3_column_text(results, 2);
[tmpItem setItemDescription:[NSString stringWithUTF8String:_charItemDescription]];
_charItemYear = (char *)sqlite3_column_text(results, 3);
[tmpItem setItemYear:[_dateFormat dateFromString:[NSString stringWithUTF8String:_charItemYear]]];
_charItemRecommendedBy = (char *)sqlite3_column_text(results, 4);
[tmpItem setItemRecommendedBy:[NSString stringWithUTF8String:_charItemRecommendedBy]];
_charItemImage = (char *)sqlite3_column_text(results, 5);
[tmpItem setItemImage:[NSString stringWithUTF8String:_charItemImage]];
[_mutableItemArray addObject:tmpItem];
#warning here I get the 2 items correct
NSLog(#"ItemName: %#",[tmpItem getItemName]);
NSLog(#"ItemName: %#",[tmpItem getItemDescription]);
}
}
sqlite3_close(_database);
#warning here I get 2 times the same item ???
NSLog(#"ItemName: %#",[_mutableItemArray objectAtIndex:0]);
NSLog(#"ItemName: %#",[_mutableItemArray objectAtIndex:1]);
return _mutableItemArray;
}
You just create one object tmpItem.
This will be added to the array and in the next run of the while loop you're not creating a new tmpItem but modifying the old one and add it to the array.
Therefore you will end up with an Array containing two pointers to the same object tmpItem (with the latest state).
Solution: create your tmpItem within the while loop.
If you go through your code you will see inside the while loop you are setting the same object (tmpItem) again and again,that is why your array has last updated values of the same object.
Now see below code you will notice in the while loop, we are creating new object and storing it in an NSArray.
- (NSMutableArray *)getItemsFromDatabaseWithName:(NSString *)databaseName fromTable:(NSString *)tableName andConstraint:(NSString *)constraint
{
NSString *absolutePath = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:databaseName];
NSLog(#"%#", absolutePath);
//Datenbank öffnen --- "**" bedeuten "&" verwenden
sqlite3_open([absolutePath UTF8String], &_database);
//check if there is a constraint and if not take 2nd statement
if (![constraint isEqualToString:#""])
{
_statement = [NSString stringWithFormat:#"select * from %# where %#",tableName, constraint];
}
else
{
_statement = [NSString stringWithFormat:#"select * from %#",tableName];
}
const char *charStatement = [_statement cStringUsingEncoding:NSUTF8StringEncoding];
sqlite3_stmt *results;
//new array to return values
_mutableItemArray = [NSMutableArray new];
//new ItemModel
if (sqlite3_prepare_v2(_database, charStatement, -1, &results, NULL)== SQLITE_OK)
{
while (sqlite3_step(results) == SQLITE_ROW)
{
ItemModel *tmpItem = [ItemModel new];
_charItemName = (char *)sqlite3_column_text(results, 1);
[tmpItem setItemName:[NSString stringWithUTF8String:_charItemName]];
_charItemDescription = (char *)sqlite3_column_text(results, 2);
[tmpItem setItemDescription:[NSString stringWithUTF8String:_charItemDescription]];
_charItemYear = (char *)sqlite3_column_text(results, 3);
[tmpItem setItemYear:[_dateFormat dateFromString:[NSString stringWithUTF8String:_charItemYear]]];
_charItemRecommendedBy = (char *)sqlite3_column_text(results, 4);
[tmpItem setItemRecommendedBy:[NSString stringWithUTF8String:_charItemRecommendedBy]];
_charItemImage = (char *)sqlite3_column_text(results, 5);
[tmpItem setItemImage:[NSString stringWithUTF8String:_charItemImage]];
[_mutableItemArray addObject:tmpItem];
NSLog(#"ItemName: %#",[tmpItem getItemName]);
NSLog(#"ItemName: %#",[tmpItem getItemDescription]);
}
}
sqlite3_close(_database);
NSLog(#"ItemName: %#",[_mutableItemArray objectAtIndex:0]);
NSLog(#"ItemName: %#",[_mutableItemArray objectAtIndex:1]);
return _mutableItemArray;
}

when I use git clone to get a git from the remote, the git_index_entrycount return 0?

I use git_repository_index to get the index first ,and then I use git_index_entrycount to see how many index items in it , but the result is 0? why? Below is my code, what's wrong with it? Thx
(void)viewDidLoad
{
[super viewDidLoad];
git_repository *repo;
progress_data pd = {{0}};
NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docPath = [array objectAtIndex:0];
git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
git_checkout_opts checkout_opts = GIT_CHECKOUT_OPTS_INIT;
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
checkout_opts.progress_cb = checkout_progress;
checkout_opts.progress_payload = &pd;
clone_opts.checkout_opts = checkout_opts;
clone_opts.fetch_progress_cb = &fetch_progress;
clone_opts.fetch_progress_payload = &pd;
clone_opts.cred_acquire_cb = cred_acquire;
NSString *pp = [docPath stringByAppendingPathComponent:#"/abc" ];
const char * a =[pp UTF8String];
int res = git_clone(&repo, "http://path/.git", a, &clone_opts);
NSLog(#"Get it. res:%d\n path:%s", res, a);
//get index
int ret;
git_index* index;
ret = git_repository_index(&index, repo);
NSLog(#"git_repository_index ret:%d", ret);
int count = git_index_entrycount(index);
if(count != 0)
{
NSLog(#"index number:%d", count);
}
else
{
NSLog(#"count == 0");
}
const git_error *err = giterr_last();
if(err == NULL)
{
NSLog(#"NULL");
}
else
{
NSLog(#"err:%s", err->message);
}
}
On order to trigger the checkout as part of the git_clone() process, have you considered using
GIT_CHECKOUT_SAFE_CREATE as the checkout_strategy?
Both this commit and the the git_checkout() documentation hint about this.

Resources