ios,exception,core-data,foundation,nsorderedsetRelated issues-Collection of common programming errors
Jordan
ios objective-c uitableview uiscrollview
Here’s how the scroll views work: One scroll view is paging enabled in the horizontal direction. Each ‘page’ of this scroll view contains a vertically scrolling UITableView. Without modification, this works OK, but not perfectly. The behaviour that’s not right: When the user scrolls up and down on the table view, but then wants to flick over to the next page quickly, the horizontal flick/swipe will not work initially – it will not work until the table view is stationary (even if the swipe is ver
EmptyStack
iphone android objective-c ios layout
I want to add a subview in the top of my view, I have to recalculate the origin y value for all of other views and re-position them to leave space for the new added view.It is very boring, as I know android have relativelayout or linearlayout can help automatically do that.How to solve this problem easily in ios development?
johnMa
ios core-data thread-safety singleton
I have a singleton name CoreDataManager which register the mergeContextChangesForNotification in it:+ (id) sharedManager{static CoreDataManager *mSharedManager = nil;static dispatch_once_t onceToken;dispatch_once(&onceToken, ^{mSharedManager = [[CoreDataManager alloc] init];});return mSharedManager; }- (id)init {self = [super init];if (self) {dispatch_async(dispatch_get_main_queue(), ^{[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(mergeContextChangesForNotification
Wytze
ios phonegap jquery-mobile event-handling page-init
I’ve got a Phonegap & jQuery Mobile app that works nicely on Android and web. On iOS I am getting unexpected results, which seem to be caused by the fact that the document.pageinit event to which I bind the handler for most of the app’s processes is fired twice.No, I didn’t bind it twice. No, I didn’t use document.ready. Yes, I did bind it to the document, early on in the script and not inside any other function.$(document).on(‘pageinit’,function(event){alert(‘ Pageinit on document’);//Some
Benoit
ios objective-c xcode unit-testing testing
I created a few test cases and they all passed… That’s because they are not being run.From Xcode, I get:Test Suite ‘All tests’ started at… Test Suite ‘All tests’ finished at… Executed 0 tests, with 0 failures (0 unexpected) in 0.00 secondsThe project (and unit test classes) build successfully. All my test classes have MyApp_appTests as Target Membership selected. Production classes have MyApp_app & MyApp_appTests targets selected.I verified the MyApp_appTests Target Build Settings (Bun
Robert Yi Jiang
ios facebook-ios-sdk
It is not redundancy question! My problems is very similar with facebook login using FBloginView not showing in ios 6 But it is not same!I have tried migrating HelloFacebookSample code into my project. I have carefully checked and compared both codes. There is no critical difference.- (void)viewDidLoad {[super viewDidLoad];FBLoginView *loginView = [[FBLoginView alloc] init];loginView.frame = CGRectOffset(loginView.frame, 45, 45);loginView.delegate = self;[self.view addSubview:loginView];[login
MarqueIV
ios ipad notifications alerts alarms
We’re creating an audio application for iPad (only) which will be used for live performances. The device will be wired directly into the console. As such, the last thing you want during a live performance is to have the device suddenly chirp out an unexpected alarm or reminder.With research in Apple’s SDK, it looks like you can block everything except calendar and alarms (and calls on iPhone).That said, does anyone know how to tell the device ‘While we’re in ‘On Air’ mode, don’t allow any OS no
Brad Robinson
ios xcode ios7
What exactly does iOS 7 use to determine whether the application should be displayed with the traditional iOS 6 style UI (aka iOS6 compatibility mode), or the newer iOS 7 UI?If I build our app in Xcode 5, with base SDK set to 7 I get the iOS 7 UI as expected If I build our app in Xcode 5, with base SDK set to 6 I still get the iOS 7 UI (unexpected, happens on real device and simulator) If I build in Xcode 4.x, I get the older UI as expectedIn all cases, the deployment target is set to 5.Since ou
Darren
ios xcode xcode4 uistoryboard
I’m just starting my first application using storyboards. I’m using Xcode 4.5 and iOS 6 SDK. I want to know how to change the order in which the controllers are listed in the Document Outline (panel to the left of the storyboard).
Jonny
ios xcode
All of a sudden today I get an unexpected problem with XCode (5).This is how I normally add an external framework:Drag-n-drop the file (xxx.framework etc) (or the folder which contains the file) into the project manager. In “Choose options for adding files” I check “Copy items into destination (if needed)” only if needed (if the files are already in the project’s folder I don’t do this) In “Folders” I select Create groups for any added folders And I add it to my app target.Normally this would al
Vyktor
c++ exception exception-handling throw
In C++ you may declare function with exception specification like this:int foo() const throw(Exception);I found those two links:http://www.cplusplus.com/doc/tutorial/exceptions/ and http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fcplr156.htmBut several things end up unanswered…Question 1: why to add exception specification? Will it bring any performance increase? What will be different for compiler? Because it seems just like a
uki
java api exception
I have a design level doubt regarding creating APIs in Java. Suppose I have a class as follows :-class Test {public final static String DEFAULT_ENCODING = “utf-8”;public byte[] encodeIt(String input){try {return input.getBytes(DEFAULT_ENCODING);} catch(UnsupportedEncodingException e) {// do something}} }I know that the UnsupportedEncodingException would never arise as I’m using a static string as the input to toBytes. It doesn’t make sense to have encodeIt do a throws UnsupportedEncodingExceptio
updogliu
c++ exception
Assume I want to define two variables of class {Type}. The constructor takes 1 argument. Are the following two ways completely equivalent (compile to the same object code)?Type a(arg), b(arg);andType a(arg); Type b(arg);This question emerges after I read a page talking about exception safety — http://www.gotw.ca/gotw/056.htm There is a guideline “Perform every resource allocation (e.g., new) in its own code statement which immediately gives the new resource to a manager object.” It gives an e
Sudhansu
objective-c cocoa exception exception-handling try-catch
I want to raise an exception inside a catch block of a method and handle it in catch of another method from where earlier method was called. I tried this logic-method B() {@try{…….// calling method where is probable chance of exceptionmethod A();}catch(NSException e){//catching the exception thrown in the method B()NSString* theError=[e reason];NSLog(@”the error is == %@”,theError);} }method A() {@try{………….//throw an exception incase of some conditionthrow e;}catch(NSException e){//
Ned Nowotny
java exception null assert preconditions
Yes, there are many questions and perfectly good answers dealing with the Java assert statement and when exceptions should be used instead. This question is about one specific use case which normally falls within the sound category of, “Never use assert to ensure preconditions,” — or words to that effect. So, please bear with me for a moment longer…All Java object references can be null and are null by default. Even enum references can be null in addition to referencing only the set of values
edelaney05
objective-c exception nsoperation
In Apple’s Concurrency Programming Guide the NSOperation subclass examples (both non-concurrent and concurrent varieties) use exception handling and I’m wondering why they are encouraging this style within operations.Listing 2-4 Responding to a cancellation request- (void)main {@try {BOOL isDone = NO;while (![self isCancelled] && !isDone) {// Do some work and set isDone to YES when finished}}@catch(…) {// Do not rethrow exceptions.} }My understanding is that generally exception handli
Barun
c# vb.net exception
I have just converted my c# code to vb.net. And it is giving exception.c# code :private static short[] muLawToPcmMap;decoded[2 * i + 1] = (byte)(muLawToPcmMap[data[i]] >> 8);vb code :decoded(2 * i + 1) = CByte(muLawToPcmMap(data(i)) >> 8)Exception :Arithmetic operation resulted in an overflow.I am in very much trouble. Please help.
Chris
php exception exception-handling
I have not yet been able to find a list of all the built-in Exception sub classes in PHP. I’d rather use built in ones when they make sense, before creating my own exception subclasses.For example, I know InvalidArgumentException exists, but there appears to be nothing comparable to Java’s NullPointerException.Does anyone have or can link to a list of the available Exception subclasses in PHP?
Tom Future
exception matlab
For example, I want to catch a couldn’t-read-a-file-at-that-path exception from imread(). I can do this.imagePath = ‘a_picture.jpg’; tryim = imread(imagePath); catch exceptionif strcmp(exception.identifier, ‘MATLAB:imread:fileOpen’)fprintf(‘Couldn”t open %s.\n’, imagePath);im = [];elsefprintf(‘Unexpected error (%s): %s\n’, …exception.identifier, exception.message);throw(exception);end endBut the only ways I know to discover the magic string to compare with (‘MATLAB:imread:fileOpen’ in this c
woliveirajr
.net exception exception-handling
In .Net:1) Do you let the exception propagate to the global error handler where you both log the error and show a msg box? The reason I ask is if you use a single global error handler to catch exceptions at the top, you’d need a bunch of Ifs to deduce the exception type and then show a message which may be friendly (e.g. for filenotfound, the file you provided was not found, etc).I have a global error handler in my winforms app. For any exceptions I cannot handle, they hit this handler where it
johnMa
ios core-data thread-safety singleton
I have a singleton name CoreDataManager which register the mergeContextChangesForNotification in it:+ (id) sharedManager{static CoreDataManager *mSharedManager = nil;static dispatch_once_t onceToken;dispatch_once(&onceToken, ^{mSharedManager = [[CoreDataManager alloc] init];});return mSharedManager; }- (id)init {self = [super init];if (self) {dispatch_async(dispatch_get_main_queue(), ^{[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(mergeContextChangesForNotification
Charles
ios core-data icloud cascading-deletes
CoreData Entity “A” has a one-to-many relationship to a collection of CoreData Entries “B”, using a Cascade delete rule.In an iCloud environment, while device 1 shows a detail view of one of the “B” entries, device 2 deletes the “A” entry.When the NSPersistentStoreDidImportUbiquitousContentChangesNotification notification is received in device 1, its App Delegate calls mergeChangesFromContextDidSaveNotification and then broadcasts an internal notification which is captured by the view controller
horseshoe7
ios objective-c core-data nsmanagedobject mogenerator
I have a project using CoreData. I use Mogenerator to generate the subclasses.When I set the value of a property, this value isn’t actually assigned. Each subsequent time I try to set the value, the previous value I set it to was not assigned.This worked fine as my underlying data framework was Mantle, but since moving to CoreData, this stopped working. I rely on KVO to keep some UIView objects up-to-date with the model.Again, the ivars of a CoreData NSManagedObject subclass do not seem to ta
Cezar
ios core-data icloud
I am implementing iCloud support in my core data app using an NSManagedDocument as the core data stack.Everything seems to be working fine but with some unexpected behavior:With the universal app installed on my iPhone and iPad:an entity added from the iPhone gets iClouded to the iPad; an entity added from the iPad gets iClouded to the iPhone; the entity added from the iPhone, deleted on the iPhone is automatically deleted on the iPad the entity added from the iPad, deleted on the iPad is autom
Simon
core-data nsmanagedobjectcontext
When we first added Core Data to our app, the tutorial we followed created an NSManagedObjectContext in our app delegate. It recommended that if we used Core Data on other threads, we should add an observer to update our main context when the thread’s context was saved, like so:[[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(mergeChanges:)name:NSManagedObjectContextDidSaveNotificationobject:self.managedObjectContext];This happens once in applicationDidFinishLoadingWithO
radven
core-data ios5 nsfetchrequest
I have a Core Data importer that loops through data, and ignores duplicate records during the import process.But I have discovered that my NSFetchRequest is not matching against recently stored records that have not been saved. And I am seeing seemingly identical queries delivering different and unexpected results.For example, in my testing, I discovered that this query matches and returns results:fetchTest.predicate = [NSPredicate predicateWithFormat:@”%K = 3882″, @”intEmployee_id”];But this se
user826955
ios core-data ios5 synchronization icloud
I have an app on the app store, that uses coredata as storage. I wan’t to update the app with iCloud synchronization as new feature. Following apple`s sample code, I managed to have my core data storage synchronize between devices.However, I’m experiencing problems when either iCloud synchronization is turned off/on in the app on only one of the devices, or when the app is deleted from the device and the reinstalled. In both cases, data is not synchronized back to the device, although it is avai
Jonas Jongejan
objective-c cocoa core-data nsmanagedobject nsmanagedobjectcontext
I have some trouble with a core data project. I have a NSArrayController with NSManagedObjects in it, and + / – buttons. If i delete a object in the row after the file has been saved it works perfectly, but if I add a new object, and immediately delete it again (without changing any of the default values), i get an error: Serious application error. Exception was caught during Core Data change processing: Unknown number type or nil passed to arithmetic function expression. with userInfo (null)
doNotCheckMyBlog
iphone objective-c ios performance core-data
I have been developing iPhone application and just started adding CoreData for persistence. However I stumbled into one dilemma,Context : I have Entity named Person, Person Entity has one Attribute name.Task : Change name of Person object.(NSManagedObject)Performance Test : Which option will be faster and better in matter of performance?Option 1 : Assuming Object has been created once onlyGet object from CoreData Edit Object’s name Save NSManagedObjectContext.Option 2 : Creating new Object each
4brunu
ios sqlite core-data indexing index
I need to improve the time of one fetch request to coredata, so I was thinking in indexing some attributes. My doubt is, I will insert the rows manually in the sqlite file with sql, so will the indexing of the attributes have any effect? Or I need to insert the data by code?
petershine
ios nsstring foundation nsobject nsdecimalnumber
I wanted to compare two strings using – (BOOL)isEqualToString:(NSString *)aString These strings are objects from a dictionary using -(id)objectForKey:(id)aKey containing numerical characters.When I check the classes of these strings using [object class], no matter how I casted them to be NSString *, it keeps showing that they are NSCFDecimal number, requiring to be compared using ==. If I wanted to use isEqualToString on them, it throws error.Can anyone explain why this is happening?
kmikael
objective-c unit-testing foundation
I’ve recently been loving unit testing after being introduced to the idea in Programming Ruby. I knew there was a preference, ‘Include Unit Tests’ in Xcode, so I tried it. First of all it was very hard to find documentation for the framework and secondly it’s a hassle to add unit tests to a Foundation command-line tool. With all of it’s separate schemes and targets etc.This got me thinking about writing a extremely minimal and easy to include unit testing framework, mainly for educational purpos
Matoe
Josh Caswell
objective-c osx nstimer foundation
I’m trying to learn about NSTimer, using Foundation and printing to the console. Can anybody tell me what I need to do to get the following to work? It compiles with no errors, but does not activate my startTimer method — nothing prints.My aim is to get one method to call another method to run some statements, and then stop after a set time.#import <Foundation/Foundation.h>@interface MyTime : NSObject {NSTimer *timer; } – (void)startTimer; @end@implementation MyTime- (void)dealloc {[time
bbum
objective-c ios osx cocoa foundation
I’m a beginner in Objective-C. I’m studying memory management in Objective-C by writing simple command line code.My environment is below.Mac OS X Mountain Lion. Xcode4.5I wrote a code below.test.m1 #import <Foundation/Foundation.h> 2 #import <stdio.h> 3 4 @interface A : NSObject 5 -(void)myprint; 6 @end 7 8 @implementation A 9 -(void)dealloc { 10 printf(“dealloc!!\n”); 11 [super dealloc]; 12 } 13 14 -(void)myprint { 15
justin
LuisABOL
objective-c cocoa foundation nsbundle objective-c-runtime
Foundation’s NSBundles are the best way to load dynamic code in Objective-C. The -load method dynamically loads the bundle’s executable code into a running program.But, which Objective-C runtime public function does the NSBundle’s -load method use to load a dynamic library and register classes, categories, protocols, methods, selectors, etc, with the Objective-C runtime? In which header is it declared?
Randy Marsh
objective-c object nsarray nil foundation
Let’s suppose I create a few objects and I add them to an array.House *myCrib = [House house]; House *johnHome = [House house]; House *lisaHome = [House house]; House *whiteHouse = [House house];NSArray *houses = [NSArray arrayWithObjects: myCrib, johnHome, lisaHome, whiteHouse, nil];Normally, all House objects have a retain count of two, but they’re being autoreleased once. After a while, I decide to release myCrib, even if I’m not the owner – I never retained or initialized.[myCrib release];Th
Mike Abdullah
multithreading cocoa core-data foundation nsindexpath
Apple’s multithreading docs don’t list NSIndexPath as threadsafe or not! As an immutable class, I’d generally expect it to be threadsafe.Previously, I’m sure the documentation used to state that NSIndexPath instances were shared and globally unique. That seems to have disappeared now though, leading me to suspect that design was revised for iOS5 / Mac OS X 10.7.I’m seeing quite a lot of crash reports from customers on Mac OS X 10.6 (Snow Leopard) which appear to be crashing trying to access an i
justin
objective-c ios nsarray foundation reference-counting
This recent SO discussion has confused me. The NSMutableArray prototype for addObject: is- (void)addObject:(id)anObjectand id is defined in objc.h astypedef struct objc_class *Class; typedef struct objc_object {Class isa; } *id; When I add an NSObject or subclass to an NSMutableArray, its retain count is incremented, and when I remove it from an NSMutableArray it is decremented. Does this mean that if an id type which is not an NSObject or subclass is added to an NSMutableArray, it has to respon
Sonny G
ios filter nsmutablearray unique nsorderedset
I have an NSObject with NSStrings inside. How do I add objects with unique obj.name only to an NSMutableArray? I tried NSOrderedSet but it only works if you add NSString to an array and not objects with NSString inside.Example.@@interface MyObject : NSObject @property (strong, nonatomic) NSString *name; @endNSMutableArray *array = {MyObject.name,MyObject.name,MyObject.name};How do I make sure that no two MyObjects have the same name?
nevan king
ios uitableview core-data ios5 nsorderedset
What are the steps that I need to perform to implement user-defined ordering in a UITableViewController with Core Data as the backing store? Do I still need to respond to -tableView:moveRowAtIndexPath:fromIndexPath:toIndexPath: or is the model re-ordering handled automatically by the table view? Can I just check the “Ordered” checkbox in the Core Data model file and expect it to transmit the changes from the table view to the store, or do I have to do more? Do I have to change the way my fetched
AlanGrant86
ios exception core-data foundation nsorderedset
i need your help i’ve got this frustrating “random” error.The app is compose of one Mapviewcontroller and a collectionview on the second controller.Sometimes when I return to the map from the second controller the app suddenly crash with this error on the the “trap” line. The crash report doesn’t point to any of my lines of code.EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe)I said “random error” because the same version of the same app could be build and run smooth for days, then sudde
Web site is in building