Search Results

Search found 3457 results on 139 pages for 'cocoa'.

Page 15/139 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • iphone - Programmatically set (System-wide) proxy settings?

    - by Andrew
    I am new to iPhone development, so I'm sorry if this is a stupid question. I am developing an application whose purpose will be to route all iPhone activity through my company's proxy. Is there a way to programmatically set system-wide proxy settings in the iPhone (which will also take effect on the 3G connection)? I know there is a way to manually set proxy settings for each wifi connection. Detecting new networks and setting the proxy on them would be acceptable. However, I need to also be able to set the proxy on the 3G connection. Also, bonus: Is there a way to programmatically change the "Restrictions" settings? If anyone has any tips or can point me in the right direction, I would appreciate it. Thanks. EDIT: Please understand that this is for a legitimate purpose. Apple has to approve app store additions, so it's not like I'm trying to spread a virus. Please, constructive answers only.

    Read the article

  • CGBitmapContextCreate issue while trying to resize images

    - by Jeff
    Hello! I'm running into an issue when I try to create a CGContextRef while attempting to resize some images: There are the errors Sun May 16 20:07:18 new-host.home app [7406] <Error>: Unable to create bitmap delegate device Sun May 16 20:07:18 new-host.home app [7406] <Error>: createBitmapContext: failed to create delegate. My code looks like this - (UIImage*) resizeImage:(UIImage*)originalImage withSize:(CGSize)newSize { CGSize originalSize = originalImage.size; CGFloat originalAspectRatio = originalSize.width / originalSize.height; CGImageRef cgImage = nil; int bitmapWidth = newSize.width; int bitmapHeight = newSize.height; CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(nil, bitmapWidth, bitmapHeight, 8, bitmapWidth * 4, colorspace, kCGImageAlphaPremultipliedLast); if (context != nil) { // Flip the coordinate system //CGContextScaleCTM(context, 1.0, -1.0); //CGContextTranslateCTM(context, 0.0, -bitmapHeight); // Black background CGRect rect = CGRectMake(0, 0, bitmapWidth, bitmapHeight); CGContextSetRGBFillColor (context, 0, 0, 0, 1); CGContextFillRect (context, rect); // Resize box to maintain aspect ratio if (originalAspectRatio < 1.0) { rect.origin.y += (rect.size.height - rect.size.width / originalAspectRatio) * 0.5; rect.size.height = rect.size.width / originalAspectRatio; } else { rect.origin.x += (rect.size.width - rect.size.height * originalAspectRatio) * 0.5; rect.size.width = rect.size.height * originalAspectRatio; } CGContextSetInterpolationQuality(context, kCGInterpolationHigh); // Draw image CGContextDrawImage (context, rect, [originalImage CGImage]); // Get image cgImage = CGBitmapContextCreateImage (context); // Release context CGContextRelease(context); } CGColorSpaceRelease(colorspace); UIImage *result = [UIImage imageWithCGImage:cgImage]; CGImageRelease (cgImage); return result; }

    Read the article

  • Core Data NSPredicate for relationships.

    - by Mugunth Kumar
    My object graph is simple. I've a feedentry object that stores info about RSS feeds and a relationship called Tag that links to "TagValues" object. Both the relation (to and inverse) are to-many. i.e, a feed can have multiple tags and a tag can be associated to multiple feeds. I referred to http://stackoverflow.com/questions/844162/how-to-do-core-data-queries-through-a-relationship and created a NSFetchRequest. But when fetch data, I get an exception stating, NSInvalidArgumentException unimplemented SQL generation for predicate What should I do? I'm a newbie to core data :( I know I've done something terribly wrong... Please help... Thanks -- NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; // Edit the entity name as appropriate. NSEntityDescription *entity = [NSEntityDescription entityForName:@"FeedEntry" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; // Edit the sort key as appropriate. NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"authorname" ascending:NO]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; NSEntityDescription *tagEntity = [NSEntityDescription entityForName:@"TagValues" inManagedObjectContext:self.managedObjectContext]; NSPredicate *tagPredicate = [NSPredicate predicateWithFormat:@"tagName LIKE[c] 'nyt'"]; NSFetchRequest *tagRequest = [[NSFetchRequest alloc] init]; [tagRequest setEntity:tagEntity]; [tagRequest setPredicate:tagPredicate]; NSError *error = nil; NSArray* predicates = [self.managedObjectContext executeFetchRequest:tagRequest error:&error]; TagValues *tv = (TagValues*) [predicates objectAtIndex:0]; NSLog(tv.tagName); // it is nyt here... NSPredicate *predicate = [NSPredicate predicateWithFormat:@"tag IN %@", predicates]; [fetchRequest setPredicate:predicate]; // Edit the section name key path and cache name if appropriate. // nil for section name key path means "no sections". NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"]; aFetchedResultsController.delegate = self; self.fetchedResultsController = aFetchedResultsController; --

    Read the article

  • UIDatePicker locale does nothing?

    - by morticae
    I'm creating a UIDatePicker programmatically, and setting its locale with the following code: datePicker.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"es_ES"] autorelease]; The datepicker still appears in English (or whatever language I've set the phone to). Anyone have any idea why this does nothing, or how to fix it?

    Read the article

  • Custom UITableViewCell won't redraw on setNeedsDisplay

    - by Andrew Portner
    I created a custom UITableViewCell class with a UIButton, a UIImage, and two UILabels. The button and the image are overlayed on top of each other, and only one is displayed at a time. The expected behavior is you touch on the button, the button disappears, and it displays the image. The UITableViewCells are set to be reused. Here's my code: Constructor: - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { unheartButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; unheartButton.backgroundColor = [UIColor clearColor]; unheartButton.frame = CGRectMake(10, 13, 20, 18); [unheartButton addTarget:self action:@selector(onButtonClick:) forControlEvents:UIControlEventTouchUpInside]; [unheartButton setBackgroundImage:[UIImage imageNamed:@"redheart.png"] forState:UIControlStateNormal]; imageView = [[UIImageView alloc] init]; imageView.frame = CGRectMake(12, 13, 16, 16); NSMutableArray *array = [[NSMutableArray alloc] init]; for (int ndx = 1; ndx < 13; ndx++) { [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"icon-loading-%d (dragged).tiff", ndx]]]; } imageView.animationImages = array; imageView.animationDuration = 1; imageView.hidden = YES; [array release]; [self.contentView addSubview:imageView]; [self.contentView addSubview:unheartButton]; return self; } } Button click: - (IBAction) onButtonClick: (id) sender { unheartButton.hidden = YES; imageView.hidden = NO; [imageView startAnimating]; [self setNeedsDisplay]; [self.contentView setNeedsDisplay]; [self.unheartButton setNeedsDisplay]; [self.imageView setNeedsDisplay]; } I'm calling setNeedsDisplay on everything, but nothing seems to happen. If I scroll off the screen and back up, the button is hidden and now the loading icon is shown, but this only happens after a scroll. I'm not sure what I need to do to get the cell to repaint.

    Read the article

  • Core Text's CTFramesetterSuggestFrameSizeWithConstraints() returns incorrect size everytime

    - by nsapplication
    According to the docs, CTFramesetterSuggestFrameSizeWithConstraints () "determines the frame size needed for a string range". Unfortunately the size returned by this function is never accurate. Here is what I am doing: NSAttributedString *string = [[[NSAttributedString alloc] initWithString:@"lorem ipsum" attributes:nil] autorelease]; CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef) string); CGSize textSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0,0), NULL, CGSizeMake(rect.size.width, CGFLOAT_MAX), NULL); The returned size always has the correct width calculated, however the height is always slightly shorter than what is expected. Is this the correct way to use this method? Is there any other way to layout Core Text? Seems I am not the only one to run into problems with this method. See https://devforums.apple.com/message/181450.

    Read the article

  • Which pattern should be used for editing properties with modal view controller on iPhone?

    - by Matthew Daugherty
    I am looking for a good pattern for performing basic property editing via a modal view on the iPhone. Assume I am putting together an application that works like the Contacts application. The "detail" view controller displays all of the contact's properties in a UITableView. When the UITableView goes into edit mode a disclosure icon is displayed in the cells. Clicking a cell causes a modal "editor" view controller to display a view that allows the user to modify the selected property. This view will often contain only a single text box or picker. The user clicks Cancel/Save and the "editor" view is dismissed and the "detail" view is updated. In this scenario, which view is responsible for updating the model? The "editor" view could update the property directly using Key-Value Coding. This appears in the CoreDataBooks example. This makes sense to me on some level because it treats the property as the model for the editor view controller. However, this is not the pattern suggested by the View Controller Programming Guide. It suggests that the "editor" view controller should define a protocol that the "detail" controller adopts. When the user indicates they are done with the edit, the "detail" view controller is called back with the entered value and it dismisses the "editor" view. Using this approach the "detail" controller updates the model. This approach seems problematic if you are using the same "editor" view for multiple properties since there is only a single call-back method. Would love to get some feedback on what approach works best.

    Read the article

  • Custom View with Bindings in a NSTableCellView

    - by Kyle Kinkade
    i have an XCode 4 project for mac desktop. It has a tableview in it that uses NSTableCellViews. The TableView is connected to an NSArrayController to provide it's content. This is using bindings for custom labels and the like, which has worked out rather well. I have a custom view that i would like to put in the NSTableCellView, which will use custom drawing based on a NSNumber value from my Table Cell View binding. Since XCode 4, you can no longer have ibplugins, which means i can no longer create custom bindings for interface builder to work with. How can I still get this value to my custom view?

    Read the article

  • Stream multiple files in _one_ ASIHTTPRequest

    - by Snej
    What is best practice to stream multiple files in one ASIHTTPRequest? Right now, for one file I use: .... ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:someUrl]; [request setShouldStreamPostDataFromDisk:YES]; [request appendPostDataFromFile:someFilePath]; [request startSynchronous]; How to stream multiple files without placing all files in memory before transmission?

    Read the article

  • iPhone Settings app and keyboard control?

    - by randallmeadows
    So I'm putting my app's preference settings into the Settings app. One of the settings is an edit text field (PSTextFieldSpecifier). When touched, the keyboard dutifully appears, I can make the edits, but when I press Return....nothing. Well, the editing is completed, but the keyboard remains. I see no way to make the keyboard go away. I also notice this same behavior in other Settings panes, including those from Apple. Do I assume correctly that this is just standard behavior and I need to just accept the fact that my Settings table has now been reduced to half size, and just deal? Furthermore, I gather there is no approved way to have a "rich" child pane display, such as that seen in Settings-General-About-Legal? Or a way to do what appears to be a -presentModalViewController, a la Settings-General-Passcode Lock?

    Read the article

  • How do I track down the source of a KVC exception: this class is not key value coding-compliant for

    - by sam
    I get this error when I try to run my app: 2010-04-29 13:49:01.355 MyApp[56123:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MyViewController 0x5112b10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key toolbar.' MyViewController used to have an IBOutlet called 'toolbar' that connected to a UIToolbar object in a nib. I decided I no longer needed the toolbar or the nib so I removed them from the project. But Xcode seems to still want to refer to 'toolbar'. Where might the reference to toolbar be if I no longer use a nib? I can synthesize a dummy 'toolbar' property to appease Xcode, but I want to avoid this kind of ugly hack.

    Read the article

  • Drawing a PDF Right-Side-Up in CGContext

    - by Carter Allen
    I'm overriding the drawRect: method in a custom UIView, and I'm doing some custom drawing. All was going well, until I needed to draw a PDF resource (a vector glyph, to be precise) into the context. First I retrieve the PDF from a file: NSURL *pdfURL = [NSURL fileURLWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"CardKit.bundle/A.pdf"]]; CGPDFDocumentRef pdfDoc = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfDoc, 1); Then I create a box with the same dimensions as the loaded PDF: CGRect box = CGPDFPageGetBoxRect(pdfPage, kCGPDFArtBox); Then I save my graphics state, so that I don't screw anything up: CGContextSaveGState(context); And then I perform a scale+translate of the CTM, theoretically flipping the whole context: CGContextScaleCTM(context, 1.0, -1.0); CGContextTranslateCTM(context, 0.0, rect.size.height); I then scale the PDF so that it fits into the view properly: CGContextScaleCTM(context, rect.size.width/box.size.width, rect.size.height/box.size.height); And finally, I draw the PDF and restore the graphics state: CGContextDrawPDFPage(context, pdfPage); CGContextRestoreGState(context); The issue is that there is nothing visible drawn. All this code should theoretically draw the PDF glyph into the view, right? If I remove the scale+translate used to flip the context, it draws perfectly: it just draws upside-down. Any ideas?

    Read the article

  • Problem dismissing multiple modal view controllers

    - by Sheehan Alam
    I am having trouble getting my modal view controllers to display properly. I have a parent view controller that is the delegate for modal view A. In modal view A I am presenting modal view B, and having the delegate dimiss modal view A. When modal view B appears it seems to display but the screen dims, and the UI locks up, but the app doesn't crash. I set animation settings to NO and I am still getting the same issue.

    Read the article

  • NSPredicate that is the equivalent of SQL's LIKE

    - by randombits
    I'm looking for a way to use NSPredicate to set a LIKE condition to fetch objects. In addition to that, an OR would be useful as well. I'm trying to do something where if a user searches "James" I can write an NSPredicate that will do the equivalent of: select * from users where firstname LIKE '%James%' OR lastname LIKE '%James%';

    Read the article

  • Design patter to keep track UITableView rows correspondance to underlying data in constant time.

    - by DenNukem
    When my model changes I want to animate changes in UITableView by inserting/deleting rows. For that I need to know the ordinal of the given row (so I can construct NSIndexPath), which I find hard to do in better-than-linear time. For example, consider that I have a list of addressbook entries which are manualy sorted by the user, i.e. there is no ordering "key" that represents the sort order. There is also a corresponding UITableView that shows one row per addressbook entry. When UITableView queries the datasource I query the NSMUtableArray populated with my entries and return required data in constant time for each row. However, if there is a change in underlying model I am getting a notification "Joe Smith, id#123 has been removed". Now I have a dilemma. A naive approach would be to scan the array, determine the index at which Joe Smith is and then ask UITableView to remove that precise row from the view, also removing it form the array. However, the scan will take linear time to finish. Now I could have an NSDictionary which allows me to find Joe Smith in constant time, but that doesn't do me a lot of good because I still need to find his ordinal index within the array in order to instruct UITableView to remove that row, which is again a linear search. I could further decide to store each object's ordinal inside the object itself to make it constant, but it will become outdated after first such update as all subsequent index values will have changed due to removal of an object. So what is the correct design pattern to accurately reflect model changes in the UITableView in costant (or at least logarithmic) time?

    Read the article

  • Binding to NSTextField Cell not working, edited value resets to default

    - by cygnus6320
    I'm working on a Core Data document application that dynamically creates NSTableColumns. The data cell type may be a checkbox, slider, etc. Programmatically binding to all cell types works, except for NSTextFieldCell. All NSTextFieldCells fail to bind, and after editing they return to their default value. This happens no matter if they're binding to a string, a number (with an NSNumberFormatter applied), or a date (NSDateFormatter applied). I'm using the following format to do all bindings: NSDictionary *textFieldOpts = [NSDictionary dictionaryWithObjectsAndKeys:@"YES", NSContinuouslyUpdatesValueBindingOption, @"YES", NSValidatesImmediatelyBindingOption, nil]; [aCell bind:@"value" toObject:[[entryAC arrangedObjects] objectAtIndex:0] withKeyPath:@"numberData" options:textFieldOpts]; Again, these statements work if the cell type is anything but an NSTextFieldCell. I threw in an observeValueForKeyPath method to log when the value changes... and for other cell types (NSSliderCell for instance) I can see the value changing, but with the NSTextFieldCell, it never, ever updates. Help!

    Read the article

  • How to set up a user Quartz2D coordinate system with scaling that avoids fuzzy drawing?

    - by jdmuys
    This topic has been scratched once or twice, but I am still puzzled. And Google was not friendly either. Since Quartz allows for arbitrary coordinate systems using affine transform, I want to be able to draw things such as floorplans using real-life coordinate, e.g. feet. So basically, for the sake of an example, I want to scale the view so that when I draw a 10x10 rectangle (think a 1-inch box for example), I get a 60x60 pixels rectangle. It works, except the rectangle I get is quite fuzzy. Another question here got an answer that explains why. However, I'm not sure I understood that reason why, and moreover, I don't know how to fix it. Here is my code: I set my coordinate system in my awakeFromNib custom view method: - (void) awakeFromNib { CGAffineTransform scale = CGAffineTransformMakeScale(6.0, 6.0); self.transform = scale; } And here is my draw routine: - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGRect r = CGRectMake(10., 10., 11., 11.); CGFloat lineWidth = 1.0; CGContextStrokeRectWithWidth(context, r, lineWidth); } The square I get is scaled just fine, but totally fuzzy. Playing with lineWidth doesn't help: when lineWidth is set smaller, it gets lighter, but not crisper. So is there a way to set up a view to have a scaled coordinate system, so that I can use my domain coordinates? Or should I go back and implementing scaling in my drawing routines? Note that this issue doesn't occur for translation or rotation. Thanks

    Read the article

  • Populating an NSPopUpButtonCell with string values

    - by sirjorj
    I am trying to populate a NSPopUpButtonCell with a list of strings. In -(init), I populate an NSArray with the values I want in the PopUp Button. How do I connect this to the NSArrayController I added in IB? Does my app delegate need an IBOutlet NSArrayController to connect to or is there a way to bind it? Also, when I bind the NSArrayController to the NSPopUpButtonCell, do which Content do I bind it to? Content or Content Values? jorj

    Read the article

  • How to use NSPredicate to catch child objects?

    - by Konstantin
    I'm new to core data and try to get all children objects of various types with one query. Say there's an "Animal" type as parent and "Cat", "Dog" and "Bird" as children. I'd like to get both cats and dogs, but not Birds in single query returned as Animal objects. Is it possible?

    Read the article

  • How to optimize Core Data query for full text search

    - by dk
    Can I optimize a Core Data query when searching for matching words in a text? (This question also pertains to the wisdom of custom SQL versus Core Data on an iPhone.) I'm working on a new (iPhone) app that is a handheld reference tool for a scientific database. The main interface is a standard searchable table view and I want as-you-type response as the user types new words. Words matches must be prefixes of words in the text. The text is composed of 100,000s of words. In my prototype I coded SQL directly. I created a separate "words" table containing every word in the text fields of the main entity. I indexed words and performed searches along the lines of SELECT id, * FROM textTable JOIN (SELECT DISTINCT textTableId FROM words WHERE word BETWEEN 'foo' AND 'fooz' ) ON id=textTableId LIMIT 50 This runs very fast. Using an IN would probably work just as well, i.e. SELECT * FROM textTable WHERE id IN (SELECT textTableId FROM words WHERE word BETWEEN 'foo' AND 'fooz' ) LIMIT 50 The LIMIT is crucial and allows me to display results quickly. I notify the user that there are too many to display if the limit is reached. This is kludgy. I've spent the last several days pondering the advantages of moving to Core Data, but I worry about the lack of control in the schema, indexing, and querying for an important query. Theoretically an NSPredicate of textField MATCHES '.*\bfoo.*' would just work, but I'm sure it will be slow. This sort of text search seems so common that I wonder what is the usual attack? Would you create a words entity as I did above and use a predicate of "word BEGINSWITH 'foo'"? Will that work as fast as my prototype? Will Core Data automatically create the right indexes? I can't find any explicit means of advising the persistent store about indexes. I see some nice advantages of Core Data in my iPhone app. The faulting and other memory considerations allow for efficient database retrievals for tableview queries without setting arbitrary limits. The object graph management allows me to easily traverse entities without writing lots of SQL. Migration features will be nice in the future. On the other hand, in a limited resource environment (iPhone) I worry that an automatically generated database will be bloated with metadata, unnecessary inverse relationships, inefficient attribute datatypes, etc. Should I dive in or proceed with caution?

    Read the article

  • How to unset delegate on UIView setAnimationDelegate: call?

    - by morticae
    I am receiving crash reports that appear to be from a UIView animation calling a delegate that has been dealloced. Thread 0 Crashed: 0 libobjc.A.dylib 0x334776f6 objc_msgSend + 18 1 UIKit 0x31c566c4 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 2 UIKit 0x31c565d2 -[UIViewAnimationState animationDidStop:finished:] 3 QuartzCore 0x30045a26 run_animation_callbacks I am setting the current view controller as the delegate for animations using the following pattern: [UIView beginAnimations:nil context:NULL]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationDuration:0.5]; [UIView setAnimationDelegate:self]; ... [UIView commitAnimations]; My question is, how do I set that delegate reference to nil in my dealloc method? Is there some way to retain a reference to an animation? Or fetch animations in progress?

    Read the article

  • How do those bitmasks actually work?

    - by mystify
    For example, this method from NSCalendar takes a bitmask: - (NSDate *)dateByAddingComponents:(NSDateComponents *)comps toDate:(NSDate *)date options:(NSUInteger)opts So options can be like: NSUInteger options = kCFCalendarUnitYear; or like: NSUInteger options = kCFCalendarUnitYear | kCFCalendarUnitMonth | kCFCalendarUnitDay; What I don't get is, how is this actually done? I mean: How can they pull out those values which are merged into options? If I wanted to program something like this, that can take a bitmask, how would that look?

    Read the article

  • Core Data passing context between methods on secondary threads

    - by JK
    My app spawns a secondary thread for some core data store maintenance. In the secondary thread, I set up a context which I then pass to other methods e.g. [self editEntriesInContext:context]. However, this causes objects fetched from the context to become invalidated in editEntries... Why does this occur? I thought the only requirements were for the secondary thread to have its own context and managed objects, which I adhere to. (Note: The context is properly retained)

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >