Search Results

Search found 3754 results on 151 pages for 'ios simulator'.

Page 64/151 | < Previous Page | 60 61 62 63 64 65 66 67 68 69 70 71  | Next Page >

  • Object leak using "retain"

    - by Abhinav
    I have a property defined with retain attribute which I am synthesizing: @property (nonatomic, retain) UISwitch *mySwitch; And inside my loadView I am doing this: self.mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 40, 20)]; And finally inside my dealloc I am doing this: self.mySwitch = nil; Am I leaking this object (mySwitch) as I have used one alloc? Should I autorelease it while assigning it frame? Please suggest.

    Read the article

  • Using NSPredicate to filter on both Core attribute and entity

    - by Ben Thompson
    I have two entities in core data (call them entityOne and entityTwo). I have a entityOne<---entityTwo relationship between them. I am now trying to code an NSPredicate to fetch entityTwo objects on the following basis: Fetch entityTwo objects that have a relationship with a specified entityOne object. Filter out those entityTwo objects which have no value for one of their attributes. I am best doing both of these in an NSPredicate or is there a better way? I am trying the following: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(attribute <> "") AND (relationship == entityOne"]; [request setPredicate:predicate]; Any pointers on coding great fully received.

    Read the article

  • RubyMotion Error When Using setTranslucent

    - by Sam Morris
    I'm getting the following error when trying rake a project I'm working on, and I can't figure out why. The message happens no matter what variable I sent it. Objective-C stub for message `setTranslucent:' type `v@:c' not precompiled. Make sure you properly link with the framework or library that defines this message Here's my app_delegate file for reference. class AppDelegate def application(application, didFinishLaunchingWithOptions:launchOptions) navigation_appearance @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) tableView = StopsController.alloc.init @window.rootViewController = UINavigationController.alloc.initWithRootViewController(tableView) @window.makeKeyAndVisible true end def navigation_appearance UINavigationBar.appearance.setBackgroundImage UIImage.imageNamed('navbar_bg.png'), forBarMetrics: UIBarMetricsDefault UINavigationBar.appearance.setTranslucent(true) UINavigationBar.appearance.setShadowImage UIImage.imageNamed('navbar_shadow.png') end end

    Read the article

  • Downloading large files with AFNetworking

    - by goodfella
    I'm trying to implement downloading of a large file and show to user current progress, but block in: -[AFURLConnectionOperation setDownloadProgressBlock:] returns incorrect bytesRead and totalBytesRead values (they are smaller than they should be). For example: If I have a 90MB file and when it downloads completely, latest block invocation in setDownloadProgressBlock: gives me totalBytesRead value about 30MB. On other side, if file is 2MB large, latest block invocation gives correct totalBytesRead 2MB value. AFNetworking is updated to the latest version from github. If AFNetworking can't do it correctly, what solution can I use? Edit: I've determined that even if file is not downloaded completely (and this happens every time with relatively big file) AFNetworking calls success block in: -[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure] I asked a similar question here about this situation, but didn't get any answers. I can check in code downloaded and real file sizes, but AFNetworking has no API for continuation of partial download.

    Read the article

  • Get 1 array from 2 arrays (using RestKit 0.20)

    - by Reez
    I'm using RestKit and was wondering how to combine two array's into one array. I already have the data being pulled in separately from API1 and API2, but I don't know how to combine them into 1 tableView. Each API is pulling in media, and I want the combined tableView to show the most recent media (like any standard timeline does these days). I will post any extra code or help as necessary, thanks so much! Below shows API1 + API2 being pulled in correctly, but not combined into the tableView. Only data from API1 shows in the tableView. ViewController.m @interface StackOverflowViewController () @property (strong, nonatomic) NSArray *hArray; @property (strong, nonatomic) NSArray *springs; @property (strong, nonatomic) RKObjectManager *eObjectManager; @property (strong, nonatomic) NSArray *iArray; @property (strong, nonatomic) NSArray *imagesArray; @property (strong, nonatomic) RKObjectManager *iObjectManager; // Wain @property (strong, nonatomic) NSMutableArray *tableDataList; // Laarme @property (nonatomic, strong) NSMutableArray *contentArray; @property (nonatomic, strong) NSDateFormatter *dateFormatter1; // Dan @property (nonatomic, strong) NSMutableArray *combinedModel; @end @implementation StackOverflowViewController @synthesize tableView = _tableView; @synthesize spring; @synthesize leaf; @synthesize theme; @synthesize hArray; @synthesize springs; @synthesize eObjectManager; @synthesize iArray; @synthesize imagesArray; @synthesize iObjectManager; // Wain @synthesize tableDataList; // Laarme @synthesize contentArray; @synthesize dateFormatter1; // Dan @synthesize combinedModel; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self configureRestKit]; [self loadMediaDan]; [self sortCombinedModel]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)configureRestKit { // API1 // initialize AFNetworking HTTPClient NSURL *baseURLE = [NSURL URLWithString:@"https://api.e.com"]; AFHTTPClient *clientE = [[AFHTTPClient alloc] initWithBaseURL:baseURLE]; // initialize RestKit RKObjectManager *eManager = [[RKObjectManager alloc] initWithHTTPClient:clientE]; self.eObjectManager = eManager; // setup object mappings RKObjectMapping *feedMapping = [RKObjectMapping mappingForClass:[Feed class]]; [feedMapping addAttributeMappingsFromArray:@[@"headline", @"premium", @"published", @"description"]]; RKObjectMapping *linksMapping = [RKObjectMapping mappingForClass:[Links class]]; RKObjectMapping *webMapping = [RKObjectMapping mappingForClass:[Web class]]; [webMapping addAttributeMappingsFromArray:@[@"href"]]; RKObjectMapping *mobileMapping = [RKObjectMapping mappingForClass:[Mobile class]]; [mobileMapping addAttributeMappingsFromArray:@[@"href"]]; RKObjectMapping *imagesMapping = [RKObjectMapping mappingForClass:[Images class]]; [imagesMapping addAttributeMappingsFromArray:@[@"height", @"width", @"url"]]; [feedMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"links" toKeyPath:@"links" withMapping:linksMapping]]; [feedMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"images" toKeyPath:@"images" withMapping:imagesMapping]]; [linksMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"web" toKeyPath:@"web" withMapping:webMapping]]; [linksMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"mobile" toKeyPath:@"mobile" withMapping:mobileMapping]]; // register mappings with the provider using a response descriptor RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:feedMapping method:RKRequestMethodGET pathPattern:nil keyPath:@"feed" statusCodes:[NSIndexSet indexSetWithIndex:200]]; [self.eObjectManager addResponseDescriptor:responseDescriptor]; // API2 // initialize AFNetworking HTTPClient NSURL *baseURLI = [NSURL URLWithString:@"https://api.i.com"]; AFHTTPClient *clientI = [[AFHTTPClient alloc] initWithBaseURL:baseURLI]; // initialize RestKit RKObjectManager *iManager = [[RKObjectManager alloc] initWithHTTPClient:clientI]; self.iObjectManager = iManager; // setup object mappings RKObjectMapping *dataMapping = [RKObjectMapping mappingForClass:[Data class]]; [dataMapping addAttributeMappingsFromArray:@[@"link", @"created_time"]]; RKObjectMapping *imagesMapping = [RKObjectMapping mappingForClass:[ImagesI class]]; [IMapping addAttributeMappingsFromArray:@[@""]]; RKObjectMapping *standardResolutionMapping = [RKObjectMapping mappingForClass:[StandardResolution class]]; [standardResolutionMapping addAttributeMappingsFromArray:@[@"url", @"width", @"height"]]; RKObjectMapping *captionMapping = [RKObjectMapping mappingForClass:[Caption class]]; [captionMapping addAttributeMappingsFromArray:@[@"text", @"created_time"]]; RKObjectMapping *userMapping = [RKObjectMapping mappingForClass:[User class]]; [userMapping addAttributeMappingsFromArray:@[@"username"]]; [dataMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"images" toKeyPath:@"images" withMapping:imagesMapping]]; [imagesMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"standard_resolution" toKeyPath:@"standard_resolution" withMapping:standardResolutionMapping]]; [dataMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"caption" toKeyPath:@"caption" withMapping:captionMapping]]; [dataMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"user" toKeyPath:@"user" withMapping:userMapping]]; // register mappings with the provider using a response descriptor RKResponseDescriptor *responseDescriptor2 = [RKResponseDescriptor responseDescriptorWithMapping:dataMapping method:RKRequestMethodGET pathPattern:nil keyPath:@"data" statusCodes:[NSIndexSet indexSetWithIndex:200]]; [self.iObjectManager addResponseDescriptor:responseDescriptor2]; } - (void)loadMedia { // Laarme contentArray = [[NSMutableArray alloc] init]; [self sortByDates]; // API1 NSString *apikey = @kCLIENTKEY; NSDictionary *queryParams = @{@"apikey" : apikey,}; [self.eObjectManager getObjectsAtPath:[NSString stringWithFormat:@"v1/n/?limit=4&leafs=%@&themes=%@", leafAbbreviation, themeID] // Changed limit to 4 for the time being parameters:queryParams success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { hArray = mappingResult.array; [self.tableView reloadData]; } failure:^(RKObjectRequestOperation *operation, NSError *error) { NSLog(@"No?: %@", error); }]; // API2 [self.iObjectManager getObjectsAtPath:[NSString stringWithFormat:@"v1/u/2/m/recent/?client_id=e999"] parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { iArray = mappingResult.array; [self.tableView reloadData]; } failure:^(RKObjectRequestOperation *operation, NSError *error) { NSLog(@"No: %@", error); }]; } // Laarme - (void)sortByDates { NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init]; //Do the dateFormatter settings, you may have to use 2 NSDateFormatters if the format is different for Data & Feed //The initialization of the dateFormatter is done before the block, because its alloc/init take some time, and you may have to declare it with "__block" //Since in your edit you do that and it seems it's the same format, just do @property (nonatomic, strong) NSDateFormatter dateFormatter; NSArray *sortedArray = [contentArray sortedArrayUsingComparator:^NSComparisonResult(id a, id b) { // Added Curly Braces around if else statements and used feedObject NSDate *aDate, *bDate; Feed *feedObject = (Feed *)a; Data *dataObject = (Data *)b; if ([a isKindOfClass:[Feed class]]) { //Feed *feedObject = (Feed *)a; aDate = [dateFormatter1 dateFromString:feedObject.published];} else { //if ([a isKindOfClass:[Data class]]) aDate = [dateFormatter2 dateFromString:dataObject.created_time];} if ([b isKindOfClass:[Feed class]]) { bDate = [dateFormatter1 dateFromString:feedObject.published];} else {//if ([b isKindOfClass:[Data class]]) bDate = [dateFormatter2 dateFromString:dataObject.created_time];} return [aDate compare:bDate]; }]; } #pragma mark - Table View - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // API1 //return hArray.count; // API2 //return iArray.count; // API1 + API2 return hArray.count + iArray.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell; if(indexPath.row < hArray.count) { // Date Change NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"MMMM d, yyyy h:mma"]; // API 1 TableViewCell *api1Cell = [tableView dequeueReusableCellWithIdentifier:@"YourAPI1Cell"]; // Do everything you need to do with the api1Cell // Use the index in 'indexPath.row' to get the object from you array // API1 Feed *feedLocal = [hArray objectAtIndex:indexPath.row]; // API1 NSString *dateString = [self timeSincePublished:feedLocal.published]; NSString *headlineText = [NSString stringWithFormat:@"%@", feedLocal.headline]; NSString *descriptionText = [NSString stringWithFormat:@"%@", feedLocal.description]; NSString *premiumText = [NSString stringWithFormat:@"%@", feedLocal.premium]; api1Cell.labelHeadline.text = [NSString stringWithFormat:@"%@", headlineText]; api1Cell.labelPublished.text = dateString; api1Cell.labelDescription.text = descriptionText; // SDWebImage API1 if ([feedLocal.images count] == 0) { // Not sure anything needed here } else { Images *imageLocal = [feedLocal.images objectAtIndex:0]; NSString *imageURL = [NSString stringWithFormat:@"%@", imageLocal.url]; NSString *imageWith = [NSString stringWithFormat:@"%@", imageLocal.width]; NSString *imageHeight = [NSString stringWithFormat:@"%@", imageLocal.height]; __weak UITableViewCell *wcell = cell; [cell.imageView setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:[UIImage imageNamed:@"X"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) { // Something }]; } cell = api1Cell; } else { // Date Change NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"MMMM d, yyyy h:mma"]; // API 2 MRWebListTableViewCellTwo *api2Cell = [tableView dequeueReusableCellWithIdentifier:@"YourAPI2Cell"]; // Do everything you need to do with the api2Cell // Remember to use 'indexPath.row - hArray.count' as the index for getting an object for your second array // API 2 Data *dataLocal = [iArray objectAtIndex:indexPath.row - hArray.count]; // API 2 NSString *dateStringI = [self timeSincePublished:dataLocal.created_time]; NSString *captionTextI = [NSString stringWithFormat:@"%@", dataLocal.caption.text]; NSString *usernameI = [NSString stringWithFormat:@"%@", dataLocal.user.username]; api2Cell.labelHeadline.text = usernameI; api2Cell.labelDescription.text = captionTextI; api2Cell.labelPublished.text = dateStringI; // SDWebImage API 2 if ([dataLocal.images count] == 0) { NSLog(@"Images Count: %lu", (unsigned long)dataLocal.images.count); // Not sure anything needed here } else { ImagesI *imageLocalI = [dataLocal.images objectAtIndex:0]; StandardResolutionI *standardResolutionLocal = [imageLocalI.standard_resolution objectAtIndex:0]; NSString *imageURLI = [NSString stringWithFormat:@"%@", standardResolutionLocal.url]; NSString *imageWithI = [NSString stringWithFormat:@"%@", standardResolutionLocal.width]; NSString *imageHeightI = [NSString stringWithFormat:@"%@", standardResolutionLocal.height]; // 11.2 __weak UITableViewCell *wcell = cell; [cell.imageView setImageWithURL:[NSURL URLWithString:imageURLI] placeholderImage:[UIImage imageNamed:@"X"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) { // Something }]; } cell = api2Cell; } return cell; } Feed.h @property (nonatomic, strong) Links *links; @property (nonatomic, strong) NSString *headline; @property (nonatomic, strong) NSString *source; @property (nonatomic, strong) NSDate *published; @property (nonatomic, strong) NSString *description; @property (nonatomic, strong) NSString *premium; @property (nonatomic, strong) NSArray *images; Data.h @property (nonatomic, strong) NSString *link; @property (nonatomic, strong) NSDate *created_time; @property (nonatomic, strong) UserI *user; @property (nonatomic, strong) NSArray *images; @property (nonatomic, strong) CaptionI *caption;

    Read the article

  • populate CoreData data model from JSON files prior to app start

    - by johannes_d
    I am creating an iPad App that displays data I got from an API in JSON format. My Core Data model has several entities(Countries, Events, Talks, ...). For each entity I have one .json file that contains all instances of the entity and its attributes as well as its relationships. I would like to populate my Core Data data model with these entities before the start of the App (otherwise it takes about 15 minutes for the iPad to create all the instances of the entities from the several JSON files using factory methods). I am currently importing the data into CoreData like this: -(void)fetchDataIntoDocument:(UIManagedDocument *)document { dispatch_queue_t dataQ = dispatch_queue_create("Data import", NULL); dispatch_async(dataQ, ^{ //Fetching data from application bundle NSURL *tedxgroupsurl = [[NSBundle mainBundle] URLForResource:@"contries" withExtension:@"json"]; NSURL *tedxeventsurl = [[NSBundle mainBundle] URLForResource:@"events" withExtension:@"json"]; //converting the JSON files to NSDictionaries NSError *error = nil; NSDictionary *countries = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL:countriesurl] options:kNilOptions error:&error]; countries = [countries objectForKey:@"countries"]; NSDictionary *events = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL:eventsurl] options:kNilOptions error:&error]; events = [events objectForKey:@"events"]; //creating entities using factory methods in NSManagedObject Subclasses (Country / Event) [document.managedObjectContext performBlock:^{ NSLog(@"creating countries"); for (NSDictionary *country in countries) { [Country countryWithCountryInfo:country inManagedObjectContext:document.managedObjectContext]; //creating Country entities } NSLog(@"creating events"); for (NSDictionary *event in events) { [Event eventWithEventInfo:event inManagedObjectContext:document.managedObjectContext]; // creating Event entities } NSLog(@"done creating, saving document"); [document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:NULL]; }]; }); dispatch_release(dataQ); } This combines the different JSON files into one UIManagedDocument which i can then perform fetchRequests on to populate tableViews, mapView, etc. I'm looking for a way to create this document outside my application & add it to the mainBundle. Then I could copy it once to the apps DocumentsDirectory and be able I use it (instead of creating the Document within the app from the original JSON files). Any help is appreciated!

    Read the article

  • UIPageViewController: How to refer the UIPicker selected Value from 1 Viewcontroller to another...

    - by Abhinav
    I am referring the code from here, please have look at the code while answering my question : http://www.ioslearner.com/wp-content/uploads/2011/12/UIPageViewControllerDemo.zip important notes and few changes: I basically have a viewcontroller and contentviewcontroller . ViewController - have following UIPAgeViewController Datasource and Deligate UIPickerView - upon next and previous page turn the value in the PickerView changes contentviewcontroller - has following UIWebview - defined in Viewdidload of contentviewcontroller which dynamically fetches a html page based upon the string value (LabelContents) sent through following method -(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController is there a way to populate the UIWebview in contentviewcontroller based upon the row selected in UIPickerView ? Kindly help.

    Read the article

  • Drag a UIView from one UIScrollView to another

    - by theDuncs
    I have two UIScrollViews on my screen and I need to be able to drag a UIView from one scrollview to the other. At the moment, I have a UILongGestureRecognizer on the UIView that I want to move, such that when the user starts dragging it, I make the view follow the touch: - (void)dragChild:(UILongPressGestureRecognizer *)longPress { [[longPress view] setCenter:[longPress locationInView:[[longPress view] superview]]]; } But when I get the boundary of the starting UIScrollView, the view disappears because it's locked into that scrollview's bounds. Is there a way to "pop" it out of the scrollview when I start dragging such that I can carry it over to the other scrollview? Also, how do I test for the "drop" location? I want to know if it's been dropped over a certain other view. Or am I going about this all the wrong way? Thanks guys

    Read the article

  • Core Data produces Analyzer warnings

    - by RickiG
    Hi I am doing the final touch ups on an app and I am getting rid of every compiler/analyzer warning. I have a bunch of Class methods that wrap my apps access to Core Data entities. This is "provoking" the analyzer. + (CDProductEntity*) newProductEntity { return (CDProductEntity*)[NSEntityDescription insertNewObjectForEntityForName:@"CDProductEntity" inManagedObjectContext:[self context]]; } Which results in an Analyzer warning: Object with +0 retain counts returned to caller where a +1 (owning) retain count is expected In the method that calls the above Class Method I have this: CDProductEntity *newEntity = [self newProductEntity]; Which results in an Analyzer warning: Method returns an Objective-C object with a +1 retain count (owning reference) Explicitly releasing or autoreleasing a Core Data entity is usually very very bad, but is that what it is asking me to do here? First it tells me it has a +0 retain count and that is bad, then it tells me it has a +1 which is also bad. What can I do to ensure that I am either dealing with a Analyzer hiccup or that I release correctly? Thanks in advance

    Read the article

  • Is this reference or code in mistake or bug?

    - by mikezang
    I copied some text from NSDate Reference as below, please check Return Value, it is said the format will be in YYYY-MM-DD HH:MM:SS ±HHMM, but I got as below in my app, so the reference is mistake? or code in mistake? Saturday, January 1, 2011 12:00:00 AM Japan Standard Time or 2011?1?1????0?00?00? ????? descriptionWithLocale: Returns a string representation of the receiver using the given locale. - (NSString *)descriptionWithLocale:(id)locale Parameters locale An NSLocale object. If you pass nil, NSDate formats the date in the same way as the description method. On Mac OS X v10.4 and earlier, this parameter was an NSDictionary object. If you pass in an NSDictionary object on Mac OS X v10.5, NSDate uses the default user locale—the same as if you passed in [NSLocale currentLocale]. Return Value A string representation of the receiver, using the given locale, or if the locale argument is nil, in the international format YYYY-MM-DD HH:MM:SS ±HHMM, where ±HHMM represents the time zone offset in hours and minutes from GMT (for example, “2001-03-24 10:45:32 +0600”)

    Read the article

  • My xcode mapview wont work when combined with webview

    - by user1715702
    I have a small problem with my mapview. When combining the mapview code with the code for webview, the app does not zoom in on my position correctly (just gives me a world overview where i´m supposed to be somewhere in California - wish I was). And it doesn´t show the pin that I have placed on a specific location. These things works perfectly fine, as long as the code does not contain anything concerning webview. Below you´ll find the code. If someone can help me to solve this, I would be som thankful! ViewController.h #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> #define METERS_PER_MILE 1609.344 @interface ViewController : UIViewController <MKMapViewDelegate>{ BOOL _doneInitialZoom; IBOutlet UIWebView *webView; } @property (weak, nonatomic) IBOutlet MKMapView *_mapView; @property (nonatomic, retain) UIWebView *webView; @end ViewController.m #import "ViewController.h" #import "NewClass.h" @interface ViewController () @end @implementation ViewController @synthesize _mapView; @synthesize webView; - (void)viewDidLoad { [super viewDidLoad]; [_mapView setMapType:MKMapTypeStandard]; [_mapView setZoomEnabled:YES]; [_mapView setScrollEnabled:YES]; MKCoordinateRegion region = { {0.0,0.0} , {0.0,0.0} }; region.center.latitude = 61.097557; region.center.longitude = 12.126545; region.span.latitudeDelta = 0.01f; region.span.longitudeDelta = 0.01f; [_mapView setRegion:region animated:YES]; newClass *ann = [[newClass alloc] init]; ann.title = @"Hjem"; ann.subtitle = @"Her bor jeg"; ann.coordinate = region.center; [_mapView addAnnotation:ann]; NSString *urlAddress = @"http://google.no"; //Create a URL object. NSURL *url = [NSURL URLWithString:urlAddress]; //URL Requst Object NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; //Load the request in the UIWebView. [webView loadRequest:requestObj]; } - (void)viewDidUnload { [self setWebView:nil]; [self set_mapView:nil]; [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } - (void)viewWillAppear:(BOOL)animated { // 1 CLLocationCoordinate2D zoomLocation; zoomLocation.latitude = 61.097557; zoomLocation.longitude = 12.126545; // 2 MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE); // 3 MKCoordinateRegion adjustedRegion = [_mapView regionThatFits:viewRegion]; // 4 [_mapView setRegion:adjustedRegion animated:YES]; } @end NewClass.h #import <UIKit/UIKit.h> #import <MapKit/MKAnnotation.h> @interface newClass : NSObject{ CLLocationCoordinate2D coordinate; NSString *title; NSString *subtitle; } @property (nonatomic, assign) CLLocationCoordinate2D coordinate; @property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *subtitle; @end NewClass.m #import "NewClass.h" @implementation newClass @synthesize coordinate, title, subtitle; @end

    Read the article

  • How to show login screen only for the first time when app launches

    - by Jaw Ali
    I want to launch the login screen when first time app launches other wise app work simple but problem is that again again it goes to login screen. here is the code which i am using in didFininsh I want the user show go to login screen first time only and next time it should show splitViewController [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],@"firstLaunch",nil]]; if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]) { [self.window addSubview:[splitViewController view]]; LoginViewController *targetController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil]; targetController.modalPresentationStyle = UIModalPresentationFullScreen; [self.splitViewController presentViewController:targetController animated:YES completion:nil]; } else { [self.window addSubview:[splitViewController view]]; } // my comment[window addSubview:splitViewController.view]; [window makeKeyAndVisible]; return YES;

    Read the article

  • pulling a value from NSMutableDictionary

    - by Jared Gross
    I have a dictionary array with a key:@"titleLabel". I am trying to load a pickerView with ONE instance of each @"titleLabel" key so that if there are multiple objects with the same @"titleLabel" only one title will be displayed. I've done some research on this forum and looked at apples docs but haven't been able to put the puzzle together. Below is my code but I am having trouble pulling the values. Right now when I run this code it throws an error Incompatible pointer types sending 'PFObject *' to parameter of type 'NSString' which i understand but am just not sure how to remedy. Cheers! else { // found messages! self.objectsArray = objects; NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; for(id obj in self.objectsArray){ PFObject *key = [self.objectsArray valueForKey:@"titleLabel"]; if(![dict objectForKey:@"titleLabel"]){ [dict setValue:obj forKey:key]; } } for (id key in dict) { NSLog(@"Objects array is %d", [self.objectsArray count]); NSLog(@"key: %@, value: %@ \n", key, [dict objectForKey:key]); } [self.pickerView reloadComponent:0]; } }];` Here is where I define the PFObject and keys: PFObject *image = [PFObject objectWithClassName:@"Images"]; [image setObject:file forKey:@"file"]; [image setObject:fileType forKey:@"fileType"]; [image setObject:title forKey:@"titleLabel"]; [image setObject:self.recipients forKey:@"recipientIds"]; [image setObject:[[PFUser currentUser] objectId] forKey:@"senderId"]; [image setObject:[[PFUser currentUser] username] forKey:@"senderName"]; [image saveInBackground];

    Read the article

  • How to use NSObject subclass?

    - by Jon
    So I've created a subclass of NSObject called Query @interface Query : NSObject @property (nonatomic, assign) NSNumber *weight; @property (nonatomic, assign) NSNumber *bodyFat; @property (nonatomic, assign) NSNumber *activityLevel; @end Is this correct for setting the object's property? In VC1: BodyFatViewController *aViewController = [[BodyFatViewController alloc]init]; aViewController.query = self.query; [self.navigationController pushViewController:aViewController animated:YES]; In VC2: - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { Query *anQuery = [[Query alloc]init]; anQuery.bodyFat = [self.bodyFatArray objectAtIndex:row]; anQuery.weight = self.query.weight; self.query = anQuery; }

    Read the article

  • keyboard in UIWebView shows and then hides itself on input focus

    - by Jake
    I have a page that's loading into a UIWebView (which takes 100% of the screen) on an iPad. When I touch a text field, the page positions the text field to the right place and the keyboard starts to come up, but then it turns around and goes back down and blur is called on the input field. When I try this same page in mobile Safari, the keyboard is able to deploy successfully. I can't figure out what the rules are for the keyboard to show successfully and stay up = and why this is different for uiwebview than safari. All my research on the subject has yielded no answers.

    Read the article

  • Wrong code coverage on of unit test

    - by KamilPyc
    I'm using code coverage for unit tests in Xcode. Everything is working except some special cases, for example protocol declaration shows wrong values. If I have : @protocol SomeProtocole <NSObject> @property (nonatomic, readonly) NSObject *example; @end I will get 0% code coverage for this file. But I have unit test that is using class that conforms to that protocol. Only solution I found so far is to filter code coverage raport to not include protocols. But I would like to see real values for protocols. Any one have some solution to fix it?

    Read the article

  • Unable to open executable - xcode

    - by Filipe Mota
    I'm getting this error...any idea how to solve it? GenerateDSYMFile /Users/fmota/Library/Developer/Xcode/DerivedData/PBTest-gvudadeakgzklbekugyiqyfyprlt/Build/Products/Debug-iphonesimulator/PBTest.app.dSYM /Users/fmota/Library/Developer/Xcode/DerivedData/PBTest-gvudadeakgzklbekugyiqyfyprlt/Build/Products/Debug-iphonesimulator/PBTest.app/PBTest cd /Users/fmota/Documents/Developer/Protobuf/PBTest setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/usr/bin/dsymutil /Users/fmota/Library/Developer/Xcode/DerivedData/PBTest-gvudadeakgzklbekugyiqyfyprlt/Build/Products/Debug-iphonesimulator/PBTest.app/PBTest -o /Users/fmota/Library/Developer/Xcode/DerivedData/PBTest-gvudadeakgzklbekugyiqyfyprlt/Build/Products/Debug-iphonesimulator/PBTest.app.dSYM error: unable to open executable '/Users/fmota/Library/Developer/Xcode/DerivedData/PBTest-gvudadeakgzklbekugyiqyfyprlt/Build/Products/Debug-iphonesimulator/PBTest.app/PBTest'

    Read the article

  • Presenting an EKCalendarChooser modally

    - by pmb
    I'm trying to present the new EKCalendarChooser in my app as a modal view. I'm doing it using the following code: EKCalendarChooser *calendarChooser = [[EKCalendarChooser alloc] initWithSelectionStyle:EKCalendarChooserSelectionStyleMultiple displayStyle:EKCalendarChooserDisplayAllCalendars eventStore:self.ekDataSource.eventStore]; calendarChooser.showsDoneButton = YES; calendarChooser.showsCancelButton = NO; calendarChooser.modalTransitionStyle = UIModalTransitionStyleCoverVertical; calendarChooser.delegate = self; [[self navigationController] presentViewController:calendarChooser animated:YES completion:nil]; The problem I'm having is that when the view is displayed, it is missing the done button. If however, I display the view using the following code: [[self navigationController] pushViewController:calendarChooser animated:YES]; It works just fine. The done button is displayed. Shouldn't the done button be shown with the presentViewController call as well? Thanks in advance for any help! pmb

    Read the article

  • Problem in UITableViewDelegate - RowSelected gives wrong NSIndexPath

    - by vlad259
    I have a UITableViewSource which I have subclassed. I'm overriding GetCell and using my own subclassed cells, like so: public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { MarketItem item=_tableItems[indexPath.Section].Items[indexPath.Row]; MarketCell cell=tableView.DequeueReusableCell(_cellIdentifier) as MarketCell; if (cell==null) { cell=new MarketCell(UITableViewCellStyle.Subtitle,_cellIdentifier,item); } // decorate the cell // ... return cell; } This works but when I get events in my UITableViewDelegate, the index path gets me the wrong cell (events like AccessoryButtonTapped, WillSelectRow etc). The Section and Row numbers look correct but when I do a tableView.CellAt(indexPath) I get the wrong cell. (The row and section numbers again look correct.) Things to note: The table is constantly being updated - items arrive in a different thread which are then InvokeOnMainThread'd Although the table is constantly updated, rows and sections are only added - nothing is re-ordered or deleted If I pause the updates when I get a 'WillSelectRow', it doesn't help Most interestingly (but not a shippable solution) if I make a new cell each time rather than doing DequeueReusableCell, it works correctly. I can't help thinking it's a stupid bug of my own making but can't find it. Any help would be most gratefully received!

    Read the article

  • How can I use Three20 to create a dynamic TTThumbsViewController that feeds from a website directory?

    - by Cory Robbins
    Hello, I'm pretty new to the iPhone developing scene, and I am designing an app for a high school band program. Part of the app needs to be an image gallery that retrieves photos from a directory on the band's website and lists them in the thumbnail view. I can't figure out how to create a thumsview that isn't directly linked to specific pictures. I currently have this setup to work with a UIWebView that points to a PHP photo album designed to look like the iPhone Photo Album. This method works, but it is not ideal, and the navigation is obviously a bit less than what would be expected. Is Three20 the right tool for this job? If not, what should I be using? Thanks!

    Read the article

  • How to sum up a fetched result's number property based on the object's category?

    - by mr_kurrupt
    I have a NSFetchRequest that is returning all my saved objects (call them Items) and storing them in an NSMutableArray. Each of these Items have a category, an amount, and some other properties. My goal is to check the category of each Item and store the sum of the amounts for objects of the same category. So if I had these Items: Red; 10.00 Blue; 20.00 Green; 5.00 Red; 5.00 Green; 15.00 then I would have an array or other type of container than has: Red; 15.00 Blue; 20.00 Green; 20.00 What would be the best way to organize the data in such a manner? I was going to create a object class (call it Totals) that just has the category and amount. As I traverse through the fetch results in a for-loop, add Items with the same category in a Totals object an store them in a NSMutableArray. The problem I ran into with that is that I'm not sure how to check if an array contains a Totals object with a specific property. Specifically, a category that already exists. So if 'Red' exists, add the amount to it, otherwise create a new Totals object with category 'Red' and a the first Item's amount. Thanks.

    Read the article

  • Custom Header in ASIHTTPREQUEST

    - by Sharon Nathaniel
    Here is my problem. I am using ASIHTTPREQUEST to send request and get response. Now my need of the time is to upload a image,audio , video or docs via PUT method with a custom header . The header takes filename , filesize,sha256sum,username,mediatype,resume as parameters. Here is the code how I am doing that . -(void)uploadFile { NSString *resume =@"0"; NSUserDefaults *userCredentials =[NSUserDefaults standardUserDefaults]; NSString *userName =[userCredentials objectForKey:@"userName"]; NSArray *objects =[NSArray arrayWithObjects:selectedMediaType,delegate.fileName,userName,fileSize,fileSHA256Sum,resume, nil]; NSArray *keys =[NSArray arrayWithObjects:@"mediatype",@"file_name",@"usrname",@"filesize",@"sha256sum",@"resume", nil]; discSentValue =[NSDictionary dictionaryWithObjects:objects forKeys:keys]; NSURL *url = [NSURL URLWithString:@"http://briareos.code20.com/putmedia.php"]; uploadMedia = [ASIFormDataRequest requestWithURL:url]; [uploadMedia addRequestHeader:@"MEDIA_UPLOAD_CUSTOM_HEADER" value:[discSentValue JSONRepresentation]]; [uploadMedia setData:dataToUpload forKey:@"File"]; [uploadMedia setDelegate:self]; [uploadMedia setRequestMethod:@"PUT"]; [uploadMedia startAsynchronous]; } But the server is unable to recognize the header , it always returns "invalid header"

    Read the article

  • Error With Sending mail (kSKPSMTPPartMessageKey is nil)

    - by user1553381
    I'm trying to send mail in iPhone using "SKPSMTPMessage" and I added the libraries, In my class I added the following code: - (IBAction)sendMail:(id)sender { // if there are a connection if ([theConnection isEqualToString:@"true"]) { if ([fromEmail.text isEqualToString:@""] || [toEmail.text isEqualToString:@""]) { UIAlertView *warning = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ??? ????? ???? ????????" delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [warning show]; }else { SKPSMTPMessage *test_smtp_message = [[SKPSMTPMessage alloc] init]; test_smtp_message.fromEmail = fromEmail.text; test_smtp_message.toEmail = toEmail.text; test_smtp_message.relayHost = @"smtp.gmail.com"; test_smtp_message.requiresAuth = YES; test_smtp_message.login = @"[email protected]"; test_smtp_message.pass = @"myPass"; test_smtp_message.wantsSecure = YES; NSString *subject= @"Suggest a book for you"; test_smtp_message.subject = [NSString stringWithFormat:@"%@ < %@ > ",fromEmail.text, subject]; test_smtp_message.delegate = self; NSMutableArray *parts_to_send = [NSMutableArray array]; NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys: @"text/plain\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey, [messageBody.text stringByAppendingString:@"\n"], kSKPSMTPPartMessageKey, @"quoted-printable", kSKPSMTPPartContentTransferEncodingKey, nil]; [parts_to_send addObject:plain_text_part]; // to send attachment NSString *image_path = [[NSBundle mainBundle] pathForResource:BookCover ofType:@"jpg"]; NSData *image_data = [NSData dataWithContentsOfFile:image_path]; NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys: @"inline;\r\n\tfilename=\"image.png\"",kSKPSMTPPartContentDispositionKey, @"base64",kSKPSMTPPartContentTransferEncodingKey, @"image/png;\r\n\tname=Success.png;\r\n\tx-unix-mode=0666",kSKPSMTPPartContentTypeKey, [image_data encodeWrappedBase64ForData],kSKPSMTPPartMessageKey, nil]; [parts_to_send addObject:image_part]; test_smtp_message.parts = parts_to_send; Spinner.hidden = NO; [Spinner startAnimating]; ProgressBar.hidden = NO; HighestState = 0; [test_smtp_message send]; } }else { UIAlertView *alertNoconnection = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ???? ???? " delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [alertNoconnection show]; } } but when I tried to send it gives me the following Exception: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString appendString:]: nil argument' and it highlighted this line in SKPSMTPMessage.m [message appendString:[part objectForKey:kSKPSMTPPartMessageKey]]; and I Can't understand what is nil exactly Can Anyone help me in this issue? Thanks in Advance.

    Read the article

  • Can't unwrap Optional.None tableviewcell

    - by Mathew Padley
    I've a table view that has a custom table view cell in it. My problem is that when i try and assign a value to a variable in the custom table view cell I get the stated error. Now, I think its because the said variable is not initialised, but its got me completely stumped. This is the custom table cell: import Foundation import UIKit class LocationGeographyTableViewCell: UITableViewCell { //@IBOutlet var Map : MKMapView; @IBOutlet var AddressLine1 : UILabel; @IBOutlet var AddressLine2 : UILabel; @IBOutlet var County : UILabel; @IBOutlet var Postcode : UILabel; @IBOutlet var Telephone : UILabel; var location = VisitedLocation(); func Build(location:VisitedLocation) -> Void { self.location = location; AddressLine1.text = "test"; } } My cell for row at index path is: override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { var addressCell = tableView.dequeueReusableCellWithIdentifier("ContactDetail") as? LocationGeographyTableViewCell; if !addressCell { addressCell = LocationGeographyTableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "ContactDetail"); } addressCell!.Build(Location); return addressCell; } As I say I'm completely baffled, the Build function calls the correct function in the tableviewcell. Any help will be gratefully appreciated. Ta

    Read the article

  • How to Add "Write a Review" / "Rate Us" Feature to My App?

    - by Ohad Regev
    I wish to add some sort of a "Write a Review" or "Rate Us" feature to my app so my customers can easily rate and review my app. Best practice I can think of is to have some sort of pop-up or open a UIWebView within my app so the user is not kicked off of my app while opening the App Store application as done in: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/myAppName"]]; Does anyone knows of a way to do that?

    Read the article

< Previous Page | 60 61 62 63 64 65 66 67 68 69 70 71  | Next Page >