[Solved] Sharing info between ViewControllers [duplicate]

U can use segues for transferring data between viewcontrollers. check this link for more details First of all, u need to declare your dateTimeString as a property in your .h file (ViewController.h) Then you can call the segue using [self performSegueWithIdentifier:@”your_segue_identifier_name” sender:self]; Then – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@”your_segue_identifier_name”]) { } } … Read more

[Solved] How to release memory in objective-c?

For screenshot #2 it looks like you’re not releasing the CGImageRef object. For this, to clean this up you should use: CGImageRelease(image); …when you’re done using the CGImageRef. More info on this (and how it differs from CFRelease) can be found at this question: Releasing CGImage (CGImageRef) Mind you, even if you’re using ARC you … Read more

[Solved] How to Parse an Array of Strings (JSON) – iOS?

use the following custom method -(NSArray *)stringArrayFromJsonFile:(NSString *)jsonFileName withKey:(NSString *)key { NSData *fileContents = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:jsonFileName ofType:@”json”]]; NSError *error; NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:fileContents options:kNilOptions error:&error]; NSArray * stringArray = [dict objectForKey:key]; return stringArray; } now call that method like NSArray* stringArray = [self stringArrayFromJsonFile:@”yourJsonFileName” withKey:@”categories”]; 1 solved How to Parse an Array … Read more

[Solved] How to read formatted string from a text file?

ok so this is how I did it … I just used the fact that ObjC is a superset of C char personName[256]; char imgFilename[512]; int personNumber; NSArray *array = [outputString componentsSeparatedByString:@”\n”]; int lines = [array count]; FILE *file = fopen([filePath UTF8String],”r”); for (int i = 0; i<lines; i++) { fscanf(file,”%d %s %s”,&personNumber, personName, imgFilename); … Read more

[Solved] How to pass NSUInteger into NSDictionary

You can use NSNumber class for doing the same: NSDictionary *parameters = @{@”index”:[NSNumber numberWithUnsignedInteger:indexPath.row]}; Or in Modern Objective C: NSDictionary *parameters = @{@”index”:@(indexPath.row)}; 0 solved How to pass NSUInteger into NSDictionary

[Solved] Beginner: Objective C errors in XCode

I saw a couple of errors: #import “RadioStations.h” ….. // Change newName to name. (like in header says) // Change this – (NSString*)newName{ – (NSString*)name{ return name; } …… – (void)setFrequency: (double)newFrequency{ frequency = newFrequency; } // This must be delete } @end solved Beginner: Objective C errors in XCode

[Solved] How to save image from NSData after doing the action of appendData?

Here is the Sample: CGSize newSize = CGSizeMake({Here give width}, {Here give height}); UIImage *myFinalImage1 = [[UIImage alloc] initWithData:concatenatedData]; UIImage *myFinalImage2 = [[UIImage alloc] initWithData:concatenatedData]; // Set up width height with values. CGSize newSize = CGSizeMake(width, height); UIGraphicsBeginImageContext( newSize ); [myFinalImage1 drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; [myFinalImage2 drawInRect:CGRectMake(newSize.width,newSize.height,newSize.width,newSize.height*2) blendMode:kCGBlendModeNormal alpha:1.0]; UIImage *mergedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 2 solved How to … Read more

[Solved] How do I create delegates in Objective-C?

An Objective-C delegate is an object that has been assigned to the delegate property another object. To create one, you define a class that implements the delegate methods you’re interested in, and mark that class as implementing the delegate protocol. For example, suppose you have a UIWebView. If you’d like to implement its delegate’s webViewDidStartLoad: … Read more

[Solved] get all user who progam Id exit in a to many relation [closed]

The parentheses do not match in your predicate. And to compare with an array or set of values, it is much less error-prone to use the %@ expansion: NSArray *wantedIds = @[@1, @2]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@”ANY programs.programId IN %@”, wantedIds]; 0 solved get all user who progam Id exit in a to many … Read more

[Solved] I have a JSON file attached below and i want to print it in the console, currently i am using xcode 4.4 [closed]

Assuming you have a file in bundle (as it wasnt clear from the question), you can read the file with following code: NSString * path = [[NSBundle mainBundle] pathForResource:@”YOU_FILE_NAME” ofType:@”txt”]; NSString *jsonString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; then print it to console using: NSLog(@”%@”,jsonString); 4 solved I have a JSON file attached below and i … Read more