я бы записать его в файл, а затем импортировать его в новое приложение. Сначала вы запустите метод в своем приложении, а затем возьмите файл из папки документов в iTunes. Добавьте его в папку документов в новом приложении и добавьте код чтения.
Чтобы сохранить его:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *stringsPlistPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"myDictionary.plist"];
BOOL success = [myDictionary writeToFile:stringsPlistPath atomically:YES];
if (success) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Your configuration file is in the Documents folder of the app which is accessible via iTunes." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"There was a problem creating the configuration file. Please try again." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
Чтобы прочитать:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *stringsPlistPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"myDictionary.plist"];
NSDictionary *loadedDictionary = [NSDictionary dictionaryWithContentsOfFile:stringsPlistPath];
Это оставит свой файл там. Если вы хотите его удалить:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
BOOL success = [fileManager removeItemAtPath:stringsPlistPath error:&error];
if (success) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"The configuration file was successfully loaded and has now been removed." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"The configuration file was successfully loaded but could not be removed. You will need to remove it manually." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
Сохраненные данные в keyChain и доступ к нему для другого проекта. Может быть, это хороший вариант для вас. –
.. Я не уверен, что понял. вы хотите поделиться NSDictionary между приложениями во время выполнения или между проектами во время компиляции –
просто хотел взять nsdictionary и сохранить свои данные в данных приложения, чтобы каждый, кто его загрузил, будет вставлен в этот nsdictionary, например, Maarten1909 предложил – Dante