ios - 如何在其他类 objective-c 中获取循环值

标签 ios objective-c xcode

我在bezier.m中有此代码

for(int x = 0; x < [globalArray count]; ++x){
    NSInteger numOfCurves = [globalArray[x] count];
    UIBezierPath *linesegment = [UIBezierPath bezierPath];
    for(int y=0; y< numOfCurves; y++){
        [UIBezierPath makeControlPoints:globalArray[x]];
        [UIBezierPath makeAnchorPoints:globalArray[x]];
        linesegment = [UIBezierPath makeTheCurve:globalArray[x]];
    }       

    strPaths = [NSString stringWithFormat:@"%@", linesegment];
    NSLog(@"log %@", strPaths);

    linesegment.lineWidth = [[self.linesWidth objectAtIndex:x] floatValue];
    [[UIColor blackColor] setStroke];
    linesegment.lineCapStyle = kCGLineCapRound;
    [linesegment stroke];
}

我需要将“strPaths”的值传递到viewcontroller.m,其输出如下
  log <UIBezierPath: 0x7fd50147ff30; <MoveTo {201, 130.5}>,
   <CurveTo {167.25000023841858, 130.6666666418314} {188.66666698455811,      130.33333332836628} {176.33333396911621, 130.16666665673256}>,
  <CurveTo {145.83333325386047, 134.75} {158.16666650772095,      131.16666662693024} {152.33333301544189, 132.33333325386047}>,
  <CurveTo {129.25000017881393, 146} {139.33333349227905, 137.16666674613953} 

    log <UIBezierPath: 0x7fd50147ff30; <MoveTo {201, 130.5}>,
       <CurveTo {167.25000023841858, 130.6666666418314} {188.66666698455811,            130.33333332836628} {176.33333396911621, 130.16666665673256}>,
       <CurveTo {145.83333325386047, 134.75} {158.16666650772095,      131.16666662693024} {152.33333301544189, 132.33333325386047}>,
       <CurveTo {129.25000017881393, 146} {139.33333349227905, 137.16666674613953}

等等....

最佳答案

您可以使用NSUserDefaults如下存储值

[[NSUserDefaults standardUserDefaults]setValue:strPaths forKey:@"strPaths"];

并按如下所示检索该数据
[[NSUserDefaults standardUserDefaults] valueForKey:@"strPaths"];

希望这可以帮助..

关于ios - 如何在其他类 objective-c 中获取循环值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31913342/

相关文章:

ios - UIButton 中的滑动手势

ios - 被邀请者如何以编程方式拒绝 Game Center 邀请?

ios - 如何为下一个/后一个 UIImageView 创建滑动

iphone - 应用在iPhone 5.1模拟器和带有iOS 5.1的真实iPhone 4上的表现有所不同

ios - 将 UIButton 添加到 AVCaptureVideoPreviewLayer?

ios - 快速高效的数据加载

php - 调用 PHP Web 服务时,来自 iOS 的 $_POST 数据丢失

ios - drawRect 不调整大小并跑出屏幕 3.5 英寸屏幕

iphone - UIActivityIndi​​catorView 不呈现

ios - 如何在点击它们时将 View 带到前面? ios