The question is how to get data from plist and how should it be a layout

This is the next question for my first queries regarding plist data. Right now, I was able to detect how users come into contact with my viewing with randomly handling the image (thanks to phytonquick).

CGPoint currentTouchLocation = [currentTouch locationInView:self];  

I'm now having problems with how to compare the value that I received from user touches made on a random image in the view, before saving the plist data with the same name as the random image that users touch. I know how to calculate the touch distance so that I can adjust the hit points.

-(CGFloat) distanceBetween: (CGPoint) point1 and: (CGPoint)point2

   NSMutableDictionary *????? = [self loadDictionaryFromPList: @"?????"];
NSNumber *1stXCoordinate = [????? objectForKey:@"1stXCoordinate"];
NSNumber *1stYCoordinate = [????? objectForKey:@"1stYCoordinate"];
if (1stXCoordinate && 1stYCoordinate)
{
    CGPoint 1stTouchLocation = CGPointMake([lastXCoordinate floatValue], [lastYCoordinate floatValue]);
    CGFloat distanceBetweenTouches = [self distanceBetween: currentTouchLocation and: 1stTouchLocation];
    if (distanceBetweenTouches < 20)
    {
        // do something here 
        NSLog(@"You hit it.");
    }
}

, plist. (, "iphone 3 dev" ), , . :

randImage <-- callout array
    p1.jpg <-- image represented by array
        tap1 <-- Array
            item 1 - x1 coordinate <-- Number
            item 2 - y1 coordinate <-- Number
            item 3 - x2 coordinate <-- Number
            item 4 - y2 coordinate <-- Number
            item 5 - x3 coordinate <-- Number
            item 6 - y3 coordinate <-- Number
        tap2 <-- Array
            item 1 - x1 coordinate <-- Number
            item 2 - y1 coordinate <-- Number
            item 3 - x2 coordinate <-- Number
            item 4 - y2 coordinate <-- Number
    p2.jpg <-- image represented by array
        tap1
            item 1....etc

-, , , . .

+1
4

plist NSDictionary:

- (NSMutableDictionary*)dictionaryFromPlist {
    NSString *filePath = @"myPlist.plist";
    NSMutableDictionary* propertyListValues = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
    return [propertyListValues autorelease];
}

- (BOOL)writeDictionaryToPlist:(NSDictionary*)plistDict{
    NSString *filePath = @"myPlist.plist";
    BOOL result = [plistDict writeToFile:filePath atomically:YES];
    return result;
}

-:

// Read key from plist dictionary
NSDictionary *dict = [self dictionaryFromPlist];
NSString *valueToPrint = [dict objectForKey:@"Executable file"];
NSLog(@"valueToPrint: %@", valueToPrint);

// Write key to plist dictionary
NSString *key = @"Icon File";
NSString *value = @"appIcon.png";
[dict setValue:value forKey:key];

// Write new plist to file using dictionary
[self writeDictionaryToPlist:dict];
+4

:

-(void)add:(NSRunningApplication *) app { 
if ([self contains:app]) return; 
[self.apps addObject:app.localizedName]; 
 [self.apps writeToFile:self.dataFile atomically:YES];
}
+1

-initWithContentsOfFile:

plists, , .

[[NSDictionary alloc] initWithContentsOfFile:@"path/to/plist"]; -valueForKey:, .

0

plist .

/ CGPoint, , CGPointFromString NSStringFromCGPoint . Apple .

, , CGPointEqualToPoint, CGRectContainsPoint, CGRectIntersectsRect CGRectContainsRect... . Apple

0

All Articles