Count number of newlines in a file
Hi, What is the smallest code I can use to count the number of occurrences of the newline character in a file with objective-c / cocoa touch? Thanks! ...
Hi, What is the smallest code I can use to count the number of occurrences of the newline character in a file with objective-c / cocoa touch? Thanks! ...
Let's say I have an NSArray of NSNumbers like this: 1, 2, 3 Then the set of all possible permutations would look something like this: 1, 2, 3 1, 3, 2 2, 1, 3 2, 3, 1 3, 1, 2 3, 2, 1 What's a good way to do this in XCode? ...
I made a method like this: -(void) doSomething:(NSString *)str { } I call it like this doSomething(foo); It doesn't work. ...
I need a function that does the same thing as the following: static public IEnumerable<string> permute(string word) { if (word.Length > 1) { char character = word[0]; foreach (string subPermute in permute(word.Substring(1))) { for (int index = 0; index <= subPermute.Length; index++) ...
Possible Duplicate: How to convert this C# code to Objective-C This code purportedly does what I need in Objective-C but it's written in a different language. So I'm trying to convert this code to objective-c but I need to understand it better. It would be easier to understand if it was in pseudocode static public IEnumerable...
I'm trying to figure out all the different ways I can create groups of 4 from 6 objects using objective-c. For example, if I had the following objects: a, b, c, d, e, f Then I could create groups like a, b, c, d b, c, d, e a, d, e, f and so on. Order doesn't matter. If I wanted to figure out all the different possibilities, what ki...
Let's say I have an array of custom objects. The custom class looks like this Person ------- name number Now let's say I want to rearrange the array of these objects so that the objects are sorted by the number. How can this be done? ...
I have a class that retrieves data from core data and stores it into a NSMutablearray. It also has a function that returns this array. datamanager.h: @interface DataManager : NSObject { NSMutableArray *feedItems; ... } @property (nonatomic, retain) NSMutableArray *feedItems; ... datamanager.m: ... -(void)loadNews{ ...
Hi! I have a JSON-string where I know where the problem is, I just can't figure out what to do. I have looked up the "forbidden characters" in a JSON-string but it just doesn't work. When you run the show-method for FBStreamDialog for iPhone a view comes up with how it's going to look like when it's finally posted on the wall. This hap...
I am getting an EXC_BAD_ACCESS when trying to push a view controller onto the navigation stack. When enabling NSZombies, I do not get any extra information for some reason, and I can't work out why. I'm pretty certain I don't need to use CFZombies. Here is the code that seems to be causing the issue: - (void)tableView:(UITableView *)tab...
I noticed in main.m it appears to recognize parameters like any c program. How can I pass arguments to the app? ...
I'm trying to port some C++ code to Objective-C. It includes iostream and sstream, but Objective-C does not recognize these. What should be done? ...
Hi all, I am trying to figure out how to take a given NSString and convert it to camel case. I have seen lots of code samples out there for going back and forth between underscores_ and camel-case, but I am dealing with strings that are capitalized. So if I had the string: 12345 SAMPLE STREET #12 or 789 N HASKELL STREET, how would I ...
Another newbie question: If I have a UIViewController with a navigation bar visible at the top and a visible toolbar at the bottom, how do I ask the view controller for the coordinates (frame, bounds) of the "visible" area of the view? (self.view.frame and self.view.bounds return null)... ...
I need to use something like NSLog but without the timestamp and newline character, so I'm using printf. How can I use this with NSString? ...
This is what I'm using [[remaining_string substringFromIndex:k] substringToIndex:1] Is there a better way? ...
Given a string and a number, this function will produce all possible combinations of n letters from that string. i.e. If I pass "abcd" and 3, then I should get the following output: abc abd acd bcd This is the code - (void)viewDidLoad { [super viewDidLoad]; [self expand_combinations:@"abcd" arg2:@"" arg3:3]; } -(void) expan...
Is there a way to set borders to a UIImage. I know how to set it for UIImageView, but my problem is the UIImage that I load up in a UIImageview wont be of the same size or aspect ratio as the UIImageView. Hence Ive kept the UIImageView mode to aspect fit. Giving a border to UIImageView now would border the entire UIImageView rather than ...
I have a UIScrollView in a UIViewController view that scrolls horizontally. How can I detect whether the scroll is at the left end or right end or somewhere in the middle? ...
The following code works perfectly and shows the correct output: - (void)viewDidLoad { [super viewDidLoad]; [self expand_combinations:@"abcd" arg2:@"" arg3:3]; } -(void) expand_combinations: (NSString *) remaining_string arg2:(NSString *)s arg3:(int) remain_depth { if(remain_depth==0) { printf("%s\n",[s UTF8Stri...