w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
NSMutableArray is empty if called from outside?
It's likely you didn't allocate the array in your init method. Just because you have declared a @property for the array, doesn't mean it's created for you: - (id)init { self = [super init]; if (self) { self.arrayTest = [NSMutableArray array]; } return self; }

Categories : IOS

NSMutableArray have error empty array
me thinks the only objectAtIndex is here. cell.detailTextLabel.text = [array objectAtIndex:indexPath.row]; seems likely array was emptied by plistget [array removeAllObjects];

Categories : Xcode

NSMutableArray empty after leaving View
This is because when you leave the view, the view controller is being released along with all of its member variables. If you want to still be able to access the array, you need yo declare it somewhere else, or make it static. EDIT: Since viewDidLoad is called every time you go back to the view, it is resetting the array back to an empty one because of [NSMutableArray new]. You want to only call that line of code when the array has not yet been created. For example, you could do: if (!favoritesArrayDetail) //Only do this code if the array is nil. favoritesArrayDetail = [NSMutableArray new];

Categories : Iphone

Deep copy of an NSMutableArray of custom objects with NSMutableArray members
In order to deep copy the content of the array [[NSMutableArray alloc] initWithArray:srcArray copyItems:YES]; will send copyWithZone: to every object inside the collection. If they don't respond to this selector, you'll get a crash. Have your CustomParent class to conform to the NSCopying protocol and you're done. Here's some extra info on how do achieve it: Implementing NSCopying

Categories : IOS

conversion from NSMutableArray of NSData to NSMutableArray of NSString?
I am not aware of anyway besides visiting each element, like: NSMutableArray *mutableArray; // your array of objects for (int i = 0; i < [mutableArray count]; i++) mutableArray[i] = [[NSString alloc] initWithData:mutableArray[i] encoding:NSUTF8StringEncoding];

Categories : IOS

Xcode Add NSMutableArray to a NSMutableArray
The problem is that you shouldn't be using removeAllObjects as it just cleans the array out (deleting the work you just did). Instead, you should be creating a new array (tempImageArray = [NSMutableArray array];).

Categories : Objective C

Min and Max Value of an NSMutableArray
You can get maximum and minimum number as below code. It may help you NSNumber * max = [array2 valueForKeyPath:@"@max.intValue"]; NSNumber * min = [array2 valueForKeyPath:@"@min.intValue"]; NSUInteger numberIndex1 = [array indexOfObject:min]; NSUInteger numberIndex2 = [array indexOfObject:max]; NSLog(@"Max Value = %d and index = %d",[max intValue],numberIndex1); NSLog(@"Min Value = %d and index = %d",[min intValue],numberIndex2);

Categories : Iphone

How to add sum of NSMutableArray
This is because you keep re-creating your "scoreTally" array so it's constantly being reset to an array with a single NSNumber object. You need to create your "scoreTally" array once and then add additional objects to it as scores keep getting added. So I'd recommend moving your "scoreTally" creation somewhere else, for example the "viewDidLoad" method of your view controller (making sure to keep "scoreTally" around via an ivar or a property).

Categories : IOS

NSMutableArray Resetting Itself?
There are good clues in your log output. There are multiple instances of the view controller (see the different values for 'self'?). They each have their own array. See this code... -(IBAction)newFileMenubar:(id)sender{ [newFileWindowControllerArray addObject:[[NewFileWindowController alloc]initWithWindowNibName:@"NewFileWindowController"]]; When you press the button associated with that action, your app builds another view controller and places it in the array. That view controller gets the awake from nib message and allocates another array, and so on. To confirm this, change the code as follows: -(IBAction)newFileMenubar:(id)sender{ [newFileWindowControllerArray addObject:@"Hello world"]; // and comment this out, for now: // [[newFileWindowControllerArra

Categories : Objective C

NSMutableArray not showing first value
The picker cannot show a random object, but a only a string (in its base configuration). Make sure you add the name or some other string attribute of your Products class to the array, (or instruct your picker's datasource to use the right field). You should really change some names of your classes and variables. If one instance of your class represents a product, the class name should be Product not Products. Also, to use a property name like all is really not intuitive - try to think of something more generic and descriptive. Also, in your for loop you set i to 0, use it once and then increase it at the end of the loop. Why? Your index set code can also be eliminated.

Categories : Iphone

NSMutableArray's objects are same
It is probably because you are using backlist.count-1 as your index instead of using i. try this: while (i!=backlist.count) { NSLog(@"%@ %@",[[backlist objectAtIndex:i] objectForKey:@"id" ],[[backlist objectAtIndex:i] objectForKey:@"name" ]);i++; }

Categories : Objective C

NSMutableArray behaviour with ARC
If it's a copy then no. If you've added it as a reference then yes. It's just a pointer to an object so any changes to your object will apply to the object reference in the array. Don't be confused by the NSMutable part of the array. The same thing happens with a normal NSArray: if you change the object, then the array will have a reference to the changed object. The mutable part only applies to the array, not the objects in the array.

Categories : IOS

NSMutableArray add the last object only
Try something like this: - (NSMutableArray*) getFairInfoArray: (NSString*) FairIdForThisMethod From: (NSMutableArray*) exibitorsForThisMethod { NSMutableArray* exibitorsWithFairId = [[NSMutableArray alloc] init]; for (ExibitorInfo* currentExibitors1 in exibitorsForThisMethod) { if ([currentExibitors1.FairId isEqualToString: FairIdForThisMethod]) { ExibitorInfo* currentExibitors2 = [[ExibitorInfo alloc] init]; [currentExibitors2 setExibitorName:currentExibitors1.exibitorName]; [currentExibitors2 setStallLocation:currentExibitors1.stallLocation]; [currentExibitors2 setExibitorCellBackGround:currentExibitors1.exibitorCellBackGround]; [currentExibitors2 setCompanyLogoURL:currentExibitors1.companyLogoURL];

Categories : Iphone

The two nsmutablearray value is getting swap with another in ios
Why are you checking tableView == pdfListnameTable ? That should be tableView isEqual:self. pdfListnameTable. Not sure that is relevant here, but if you have more than one tableView - i'd guess that you aren't switching to it as there seems to be a lack of an else statement for that.

Categories : IOS

IOS: save an NSMutableArray
You should read : https://developer.apple.com/library/mac/#documentation/cocoa/reference/foundation/Protocols/NSCoding_Protocol/Reference/Reference.html You need to implement initWithCoder and encodeWithCoder. To save to file, just do : [NSKeyedArchiver archiveRootObject:myArray toFile:@"someFile"]; to load it: NSMutableArray* myArray = [NSKeyedUnarchiver unarchiveObjectWithFile:@"someFile"];

Categories : IOS

bool for key in NSMutableArray
Use index instead of key for an array. NSDictionary dictionary = (NSDictionary *)dataArray[0]; if ([(NSNumber *)[dictionary objectForKey:@"success"] boolValue]) { // ... }

Categories : Iphone

ios compare two NSMutableArray
Jason, I am not pretty sure about what your requirements are but as per I understand predicate is answer for your question, which are very helpful for searching. Block predicates have made it very easy to use. NSArray *allFbIds = [self.myPersonArray valueForKeyPath:@"UserDef2"]; NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { NSDictionary *data = (NSDictionary *)evaluatedObject; NSString *fbid = [data objectForKey:@"id"]; return [allFbIds containsObject:fbid]; }]; NSArray *filetr = [array filteredArrayUsingPredicate:predicate]; If any of fbID will be available in property UserDef2 in KP_PERSON object of myPersonArray that will be in the filtered in the array. I think this might solve your problem.

Categories : Iphone

Tests using rspec, capybara and poltergeist return empty html and empty screenshots
So eventually I got help from a colleague, and we managed to fix it. We used the lvh.me domain for this, as any request to that domain will resolve in localhost, allowing you to use subdomains without a problem. You could probably also use hostname.127.0.0.1.xip.io for this. Our spec_helper.rb now looks like this: # Use capybara in combination with poltergeist for integration tests require 'capybara/rails' require 'capybara/rspec' require 'capybara/poltergeist' require 'rack_session_access/capybara' Capybara.default_driver = :poltergeist Capybara.always_include_port = true Capybara.app_host = 'http://application-test.lvh.me' # Any lvh.me domain resolves to localhost Capybara.default_wait_time = 8 # How long capybara should look for html elements require 'vcr' VCR

Categories : Ruby On Rails

Why is a empty variable declaration of type String "null" and not "" (blank or empty)
It's not "null", it's null. But println displays it like that because it's defined to do so (see the Javadocs). As for why it's not initialized to an empty string, that's because String is a class type, and the default value for references to class instances is always null. There is a big difference between no object at all (i.e. null) and an object in an "empty" state.

Categories : Java

jQuery ajax call returns empty error if the content is empty
dataType: "json" means: give me json, nothing else. an empty string is not json, so recieving an empty string means that it wasn't a success... request = $.ajax({ type: "POST", url: url, data: { .... }, error: function() { console.log("error"); }, success: function(res) { var response=jQuery.parseJSON(res); if(typeof response =='object'){ if(response.reply=='2') { getResult(); } } else { //response is empty } } });

Categories : Jquery

Force JAXB to Interpret Empty Element as Null not Empty String
Since this is just for one element, below is one way you could get this to work with any JAXB implementation. Java Model Foo Setup your class to use field access by leveraging the @XmlAccessorType annotation. Then initialize the field corresponding to the element as "". The implement the get/set methods to treat "" as null. import javax.xml.bind.annotation.*; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Foo { private String bar = ""; public String getBar() { if(bar.length() == 0) { return null; } else { return bar; } } public void setBar(String bar) { if(null == bar) { this.bar = ""; } else { this.bar = bar; } } } Demo Code Below is some de

Categories : Java

Check if textbox is empty, and if it is empty I want plugin from bootstrap, to popover but it's not working
You're using the check variable inside your each, but that variable is still a reference to the entire set of inputs. You want to check this.value, which will be a reference to the element at the current step in the iteration (and similarly, $(this).popover()).

Categories : Javascript

How to bind the NSMutableArray to ArrayController through xib
The steps are as follows (just in case you missed anything): Add the array controller Set the Mode of the array controller to Class and add the Class name. Add the Keys you want to bind If you are using and View based table view. Do following: Click the column in your table view (often takes three clicks on the table view) Check Value in Bindings Inspector Controller Key: ArrangedObjects and your Model Key Path. Mark your Static Text in your table view cell. Bind your Static Text to Table Cell View and your Model Key Path. Hope it helps!

Categories : Objective C

Setting elements in NSMutableArray to nil
When using ARC, you release a variable by setting it to nil just as you have done with arr = nil. Note that the memory will only be freed when all pointers to the object have been set to nil, so make sure you aren't holding on to them anywhere else. Secondly, if you are running into memory issues you should be handling this in the didReceiveMemoryWarning method, as viewDidUnload is no longer supported on iOS 6.

Categories : Objective C

used memory: c-array vs. NSMutableArray
It's pretty clear that the memory consumption of NSArray will be bigger than of a raw C array. How big the difference will be? Well, for every value in a NSArray, every primitive double has to be wrapped by a NSNumber so at least 20 B added for every value, probably a bit more. One estimate can be found here: Memory size of classes in Objective-C Anyway, storing 1 000 000 values in memory is always a bit strange. Maybe it would be better to store them in a file and then load them when needed (e.g. using a memory mapped file).

Categories : Objective C

NSMutableArray key value coding error
You are building the dictionary incorrectly. Why not just do: NSMutableDictionary *soundDict = [@{ @"Random" : @NO, @"Cricket" : @NO, @"Mosquito" : @NO, @"Fly" : @NO, @"Owl" : @NO, @"Scratching" : @NO, @"Whistle" : @NO } mutableCopy]; Then your setSoundDictValue:forKey: method becomes: - (void)setSoundDictValue:(BOOL)value forKey:(NSString *)key { sound[key] = @(value); } The problem with your code is easier to see if you split it up: - (void)setSoundDictValue:(BOOL)value forKey:(NSString *)key { NSArray *sounds = [soundDict objectForKey:@"Sound Values"]; [sounds setValue:[NSNumber numberWithBool:value] forKey:key]; } As you can see, you try to call setValue:forKey: on an NSArray.

Categories : IOS

Persisting UIBezierPaths in NSMutableArray
This is happening because you are using a global instance path . Instead of using a global instance add your path object to mutable array and get wherever you want. Try replacing your code something like this. @interface MyCustomView : UIView { NSMutableArray *paths; // this is initialized in the init method } The path is initialized in touchesBegan as follows: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UIBezierPath *path = [[UIBezierPath alloc] init]; [path moveToPoint:[touch locationInView:self]; [paths addObject:path]; } It is moved in the touchesMoved method as follows: - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UIBezierPath *path = [paths lastObject]; [path addLineToPath:[touch

Categories : IOS

Try to present uitableview with nsmutablearray
Please try this code, It might helps you. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [allListReceived count]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 44.0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TopCell"; MyCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray* views = [[NSBundle mainBundle] loadNibNamed

Categories : IOS

Split an NSMutableArray into other NSMutableArrays
Yes To divide the NSMutableArray you can use the NSArray method - (NSArray *)subarrayWithRange:(NSRange)range NSRange is a struct that is a start location and number of items. So you would want 0 and 10, 10 and 10, 20 and 10, etc. Use the following function to make your arrays: NSRange NSMakeRange (NSUInteger loc, NSUInteger len ); Hope that helps.

Categories : IOS

What is more efficient? Table using NSMutableArray
Reusing the old NSMutableArray will be more efficient as that will reuse the same memory (memory is not released when you remove all elements from an array). It is unlikely this will affect performance in a notable way in your situation though, as you would need to do it thousands of times for it to have an impact on performance.

Categories : Misc

NSMutableArray doesn't get XML values
Probably what you need to do is wait for the process to get completed and the block literally doesn't know what your doing inside it or i would say the inside function is not been captured by the block.so use the array(call the function which is using your array) only after block gets completed. Example: TBXMLSuccessBlock s = ^(TBXML *tbxml) { NSLog(@"yes"); // Do something with TBXML object "tbxml/add it ur array //Here you call the function which is about to use your array. }; //Not outside the block. EDIT : Refer this==> How do I avoid capturing self in blocks when implementing an API?

Categories : Iphone

how to add object from one key NSDictionary in NSMutableArray
Since it appears that you store arrays as NSDictionary elements, you can do this: NSMutableArray *array = [[NSMutableArray alloc] initiWithArray:dic[@"number1"]]; or NSMutableArray *array = [NSMutableArray arrayWithArray:dic[@"number1"]];

Categories : Objective C

Filling UITableview with NSMutableArray
Assuming your array is self.tableContent -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary *object = self.tableContent[index.section][index.row]; ..... some cell code cell.title = object[@"title"]; }

Categories : Iphone

How to get the index of a particular object in NSMutablearray?
In your case, your consol describe as a Dictionary and you can get specific index of Object by indexOfObject of NSMutableArray int index = [[myDic objectForKey:@"notification_list"] indexOfObject:yourSearchString]; NSLog(@"index From Array - %d", index);

Categories : IOS

NSMutableArray Labels iphoneapp
You need to iterate over the items in the array and call the method on each label: for (UILabel *label in _labels) { label.textColor = [UIColor colorWithRed:137.0f/255.0f green:200.0f/255.0f blue:255.0f/255.0f alpha:1.0f]; } The array won't do the messaging for you unless you ask it to: [_labels makeObjectsPerformSelector:@selector(setTextColor:) withObject:[UIColor colorWithRed:137.0f/255.0f green:200.0f/255.0f blue:255.0f/255.0f alpha:1.0f]];

Categories : Objective C

Is it normal to have such NSMutableArray structure
Your debug output shows an array of arrays of strings. That is to say: Your top level object (arrayofFavouritesNames) is an array. Each element of the top-level array is an array. Each element of each second-level array is a string. So you are setting name to an array, not a string. Set it to a string before you add it to arrayofFavouritesNames. If you need more help, edit your question to show us how you set name.

Categories : IOS

predicateWithFormat NSMutableArray Issue
Your array does not contain strings, but custom foodProducts objects. To filter the objects by "product name", you would use [NSPredicate predicateWithFormat:@"productName CONTAINS[cd] %@", searchText]; ADDED: There is another error in your code: cell.textLabel.text = [searchResults objectAtIndex:indexPath.row]; cannot work because the right-hand side does not return a string. It should be foodProducts *currentProduct = [searchResults objectAtIndex:indexPath.row]; cell.textLabel.text = currentProduct.productName;

Categories : IOS

How to test if there is an _NSCFConstantString in an NSMutableArray?
But this does not work, I'm assuming because the empty string in my array is of type _NSCFConstantString...? Not quite. _NSCFConstantString is a concrete subclass of NSString, so it should work. Maybe the string is not really and empty string, or it isn't in the array. Check if it's a space (or more of them), by accident. Examine its length property, etc. By the way, it's a very bad idea to modify a mutable collection while enumerating it, it can lead to logic errors. Maybe that's also part of your current problem in this case.

Categories : IOS

Why NSMutableArray doesn't get sorted?
-sortedArrayUsingSelector: is actually an NSArray method that returns a new sorted array (which you promptly ignore). You mean to use -sortUsingSelector:, which is an NSMutableArray method that rearranges the existing array itself. It's pretty common in Cocoa to have one method for returning a modified immutable version of an object, and another method for modifying the mutable object itself (-stringByAppendingString: and -appendString:, for example).

Categories : Objective C

modify an nsmutablearray in another class
Use replaceObjectAtIndex:withObject: or, with the new objective-c literals it's much easier: NSMutableArray *myArray = [NSMutableArray array]; myArray[0] = @(YES); // the same as: [myArray addObject:[NSNumber numberWithBool:YES]]; myArray[0] = @(NO); // the same as: [myArray replaceObjectAtIndex:0 withObject:[NSNumber numberWithBool:YES]];

Categories : IOS



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.