小编Sip*_*oza的帖子

如何在核心数据中存储图像

我是iOS的新手.我一直在尝试制作一个应用程序,将从相机捕获的图像存储到其中CoreData.我现在知道如何存储像NSStrings NSDate和其他类型的数据,但努力存储图像.我读了很多文章说你必须把它写到磁盘上并写入文件,但我似乎无法理解它.

以下代码是我用于将其他数据存储到核心数据的代码.

- (IBAction)submitReportButton:(id)sender
{
    UrbanRangerAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

    managedObjectContext = [appDelegate managedObjectContext];

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"PotholesDB" inManagedObjectContext:appDelegate.managedObjectContext];
    NSManagedObject *newPothole = [[NSManagedObject alloc]initWithEntity:entity insertIntoManagedObjectContext:managedObjectContext];


    [newPothole setValue:self.relevantBody.text forKey:@"relevantBody"];
    [newPothole setValue:self.subjectReport.text forKey:@"subjectReport"];
    [newPothole setValue:self.detailReport.text forKey:@"detailReport"];
//    [newPothole setValue:self.imageView forKey:@"photo"];

    NSDate *now = [NSDate date];
    //NSLog(@"now : %@", now);
    NSString *strDate = [[NSString alloc] initWithFormat:@"%@", now];
    NSArray *arr = [strDate componentsSeparatedByString:@" "];
    NSString *str;
    str = [arr objectAtIndex:0];
    NSLog(@"now : %@", str);

    [newPothole setValue:now …
Run Code Online (Sandbox Code Playgroud)

core-data objective-c ios

72
推荐指数
4
解决办法
8万
查看次数

对Amazon Cognito的AWS身份验证

我是移动设备上的新手.我正在尝试进行身份验证Amazon Cognito.我首先Credentials Provider使用自定义服务模型登录使用用户名,密码,平台和deviceToken - 然后我获取identityId,endPoint和token.有人告诉我,我需要换我回来的令牌,并刷新我的凭据,以便我经过身份验证才能AWS CognitoS3.但是所有过程都令人困惑,并且有很多不同的例子.

我创建了一个SignInProvider,扩展了AWSSignInProvider以访问 - (void)登录:(void(^)(id result,NSError*error))completionHanlder; 我在我的登录方法中有我的令牌,端点和identityId.我对完成处理程序做了什么,接下来是什么呢.

@implementation SignInProvider

+(instanceType) sharedInstance{}

- (NSString) identityProviderName{}

- (AWSTask<NSString*>*) token{}

- (BOOL) isLoggedIn{}

- (NSSting*) userName{}

- (void) reloadSession{}

- (void) login: (void (^) (id result, NSError *error)) completionHanlder{

authRequest = [IMPCLDMobileAuthenticationRequest new];



     [authRequest setToken:@"930fc1b56d8ca19a84500f9a79af71b65f60331f0242ce4395cdf41186443692"];

        [authRequest setPassword:@"pin"];

        [authRequest setUsername:@"example@email.co.za"];

        [authRequest setPlatform:@"ios"];

        serviceClient = [IMPCLDImpressionInternalMicroserviceClient defaultClient];


        [[serviceClient mobileAuthenticationPost:authRequest] continueWithBlock:^id(AWSTask *loginTask)
     {


    //what to do here with my loginTask results (token, endpoint, identityId) …
Run Code Online (Sandbox Code Playgroud)

authentication objective-c amazon-s3 amazon-web-services ios

11
推荐指数
1
解决办法
241
查看次数

如何从iOS目录中没有文件名的目录中获取文件路径

美好的一天

如何从完整路径获取没有fileName的filePath.让我们说我有一条路:

NSString*myPath = @"/ Users/myName/Library/Developer/CoreSimulator/Devices /.../ Library/Caches/Getting Started.pdf";

我想要

NSString*newPath = @"/ Users/myName/Library/Developer/CoreSimulator/Devices /.../ Library/Caches";

我不想将其子串,我希望有更好的解决方案.

先感谢您.

objective-c

1
推荐指数
1
解决办法
972
查看次数