I have NSMutableArray which contains both name and photo's string of a contact list.

[contactArray addObject:[[Contact alloc]initWithName:cName andPhoto:cPhoto]];

I want to make a contact list, so I sorted that array based on name like this:

NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
      [contactArray sortUsingDescriptors:[NSArray arrayWithObject:descriptor]];

Now I want to group it to sections with initial of only name in my array and index from # to Z to directly guide me to exact section. Can you help me solve this problem?

By using cocoapods with swift does not work because by creating bridge header file to include header file integrated using pods then error occurs displaying file not found though it is present in pod section

how should i integrate header file from pod to my project??

Below I have code for a friends list tableview that has custom tableview cells that can be slided to the right to reveal 3 buttons. 1 of those buttons is the removeFriend button.

The button is supposed to delete the friend from the friend lists. And the table should then reload with the updated tableview that has the friend removed.
The deleted friend does not disapear from the tableview until I leave the view and then go back into the view.

The server is sending the updated JSON friend list data with the deleted friend removed. What exactly could I be doing wrong?

The code being used is below:

-(void) deleteAction:(id) sender
UIButton * btn = (UIButton *) sender;  // delete friend

NSLog(@"%d", btn.tag);

self.dic = [friendsList objectAtIndex:btn.tag];

NSString * friendID = [self.dic objectForKey:@"id"];

NSLog(@"rejected ID : %@", friendID);
deleteAlert=[[UIAlertView alloc]initWithTitle:@"Friend Removal Confirmation" message:@"\n\nAre you sure you want to remove this friend\n\n\n\n" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
[deleteAlert show];


-(void) deleteAction2

NSString * friendID = [self.dic objectForKey:@"id"];

[self removeFriend:friendID];


-(void) removeFriend:(NSString *) friendId
NSString * userID = [[NSUserDefaults standardUserDefaults]  objectForKey:USERID];

NSMutableDictionary* params =[NSMutableDictionary dictionaryWithObjectsAndKeys:@"removeFriend", @"command", friendId,@"Requesterid", userID/*friendId*/, @"userid", nil];
NSLog( @"%@", params);
[SVProgressHUD showWithStatus:@"Loading..." maskType:SVProgressHUDMaskTypeBlack];

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager POST:BaseURLString parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {

    NSLog(@"JSON: %@", responseObject);

    [SVProgressHUD dismiss];

    NSString * error = [responseObject objectForKey:@"error"];

        [[[UIAlertView alloc] initWithTitle:@"Error" message:error delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil] show];
        friendsList = [NSMutableArray arrayWithArray:[(NSDictionary *)responseObject objectForKey:@"result"]];

    //        else
    //            [[[UIAlertView alloc] initWithTitle:@"Alert" message:@"You sent request." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil] show];

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

    [SVProgressHUD dismiss];

    NSLog(@"Error: %@", error);
  [friendsTableView reloadData];

#pragma alertview delegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if(alertView == addFriendAlert)

    if(buttonIndex == 1)
        addFriendId = [addFriendAlert textFieldAtIndex:0].text;

        if([addFriendId isEqualToString:@""])

        NSLog(@"%@", addFriendId);

        [self sendingFriendAddRequest:addFriendId];

if(alertView == deleteAlert){

if([title isEqualToString:@"NO"])
    NSLog(@"Nothing to do here");
else if([title isEqualToString:@"YES"])
    NSLog(@"Delete the cell");
    [self deleteAction2];

Anyone is getting this message while trying to show UIActionSheet from popover?

Your application has presented a UIAlertController () of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.

Previously to the GM I used some workaround for converting the UIActionSheet to UIAlertController and this is working fine. However it seems that Apple tried to solve the UIActionSheet issues and I didn't want to use my workaround - but it seems that I have no choice...

If the app starts, I need to select table row of the last element, that was used. The name of the last used element I save in plist. The code I used is:

id plist = [[PlistHandler alloc] init];// FIXME: Dont work with long list, if the element is out of view. 
    if ([tableData containsObject:[plist readDataForKey:@"selectedFile"]]) {
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[tableData indexOfObject:[plist readDataForKey:@"selectedFile"]] inSection:0];
        [self.fileTable selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
        [self tableView:self.fileTable didSelectRowAtIndexPath:indexPath];

The problem I found is: If the row is out of view ( table is big and the element if lower then view), I get some exception: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: selectedFile)' Maybe someone know the better way to select a row or to work around.

UPDATE: I debuged a bit and now I know where the issue happen:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSString *cellText = cell.textLabel.text;
    id plist = [[PlistHandler alloc] init];
    [plist writeDataToKey:@"path" andData:[NSString stringWithFormat:@"%@/%@", documentsDirectory, cellText]];
    [plist writeDataToKey:@"selectedFile" andData:cellText];

It's on the last line, because the cellText is nil, so maybe the index is wrong. Bit why it works with the elements, that are in the view.

How to delete all objects of an Entity which has a relationship with other entity.

Here which i tried


     managedObjectContext = ((AppDelegate *)[[UIApplication sharedApplication]delegate]).managedObjectContext;

for (Customer *customer in fetchedCustomers) {

       for(IO_Address *address in customer.customer_addresses)
            [managedObjectContext deleteObject:address];

       [managedObjectContext deleteObject:customer];

NSError *error;

if (![managedObjectContext save:&error]) {

       NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);


when i`m trying getting this error:

CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. *** Collection <__NSCFSet: 0xbf7fe00> was mutated while being enumerated. with userInfo (null)

2014-09-09 19:03:43.278 iOrder[19807:60b] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSCFSet: 0xbf7fe00> was mutated while being enumerated.'

Can anyone tell me solution.....Thanks in advance

I'm trying to pass data from the modal ViewController to his source ViewController. I think I have to use delegation but it doesn't work.

protocol communicationControllerCamera{
    func backFromCamera()

class Camera: UIViewController{
    var delegate: communicationControllerCamera


class SceneBuilder: UIViewController, communicationControllerCamera{
    func backFromCamera(){    // Never called

The backFromCamera method it's not called. What did I do wrong?

I want to make an authentification with token and login system .

First the user get a token to be identified by the server. Then if he want acces some specific function of the app he can register then login ( he have to send token for login).

Both of token and login can expire. I've done a system where I send a notification when my request "A" fail, then i can check what kind of error it is. If it is a 401 error then i catch it and launch token and/ or login then launch again my operation "A".

resume of possibility :

A -> Retoken -> A
A - > Relogin -> A
A -> relogin -> retoken -> relogin -> A

But i have a problem when i'm getting new token, i want to update the token in header before relogin or relaunch my operation A.

But I can't access headers. Is that normal ? how can i access it by AFHTTPRequestOperation?

I use custom AFHTTPRequestOperationManager and custom AFHTTPRequestOperation.

for exemple : Here is my create operation function where i modify headers in NSMutableURLRequest before creating it.

How could I change header after creating operation ?

NSMutableURLRequest * requestMutable = [self setRequestHeaderValue:[request mutableCopy]];
    AFHTTPRequestOperation* operation;
    if (isPrivate){
        operation = [[PrivateAFJSONRequestOperation alloc] initWithRequest:requestMutable];
        operation = [[PublicAFJSONRequestOperation alloc] initWithRequest:requestMutable];
    operation.responseSerializer = self.responseSerializer;
    operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage;
    operation.credential = self.credential;
    operation.securityPolicy = self.securityPolicy;

    [operation setCompletionBlockWithSuccess:success failure:failure];
    operation.completionQueue = self.completionQueue;
    operation.completionGroup = self.completionGroup;
    [operation setUploadProgressBlock:progress];

// How to modify header here (i already modified it at top but here it is close to what I need later in another method)

if you want more detail tell me.


Im creating different UITextField for different type of input(date,picker etc). Im already using tag to identify different textFields of each type.

how can i identify textfield without tag. Can i assign string identifier to textFields?

I use EkEvent in my application ios for each event i want to add url Image and url Audio. How can i add this new property in the event of EkEvent? I tried to add this on field notes but i'm afraid that calendar of ical use this field? Can i add a object tag in event for example? thanks for your responses

Can I compile my iOS app for iOS 7 using Xcode 5 and submit to app store? Or is it mandatory that i have to compile my app for iOS 8 and use XCode 6 to submit the app?

Note: I have tested my iOS app on iOS 8 beta release. App supports iOS 8.

I have one more question - If I compile my app for iOS 8 will the app runs on iOS 7?

Terminating app due to uncaught exception 'com.gigya.GigyaSDK:InvalidOperationException', reason: 'Already logged in, log out before attempting to login again' * First throw call stack:

Even I used [Gigya logout] prior to login statement in ios SDK, This issue happens when i try to login with facebook and Google plus

I am successful in changing the text of the right navigation button by given code. But i also want to change it has a delfault background .

I simply want to show a text with transparent background.

I have also tried

 UIBarButtonItem *rightBtn=[[UIBarButtonItem alloc] initWithTitle:@"MyTitle" style:UIBarButtonItemStyleDone target:self action:@selector(myMethod)];

rightBtn.tintColor =[UIColor clearColor];

but still showing a button background.

Is there a way to achieve it by changing any different style which don't have background. or is there an other simple way to change button to a text with no transparent background.

I want a lazily-initialized property whose initializer I can invoke again if I set the property to nil.

If I define my property this way:

lazy var object = { /*init code*/ }()

...and later invoke the property, the initializer is triggered once. However, if I set object to nil later in my program, the initializer is not invoked again. How can I do that in Swift?

CKContainer's performQuery method get called recursively as a depth-first search, and at the 5th level it does not return. What can I do, why it happens? Is it a CloudKit limitation? Is it any documentation about it? Have you met with similar?

func sth() {
    // init here entityName, predicate..
    publicDatabase.performQuery(CKQuery(recordType: entityName, predicate: predicate), inZoneWithID: nil, completionHandler: {records, error in

        if error == nil {  //at 5th level neither this line ..

            let temporaryContext = NSManagedObjectContext(concurrencyType: .PrivateQueueConcurrencyType)
            temporaryContext.parentContext = Utility.managedObjectContext()

        } else {
    dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER)
    println("log 2") // nor that line is get called

I'm trying to make an application in which on tapping the cell it should take me to another view controller where I can update the information of the cell.

I'm developing an app for ios 7 in Xcode 5 using storyboards where the user uses a push segue to push over to a UITabBarController with 2 UIViewControllers "in it". Here's a cropped screenshot over the ViewControllers.

I've got this code in my UITabBarController:

#import "ViewTVTabBarController.h"
#import "MyManager.h"

@interface ViewTVTabBarController ()


@implementation ViewTVTabBarController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
return self;

- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view.

// Set the BarTintcolor to red and text colors to white
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];

// Set the NavigationItem Title
self.navigationItem.title = [[MyManager sharedManager] selectedTV];

- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
- (IBAction)actionBarButton:(id)sender {
// Offer options for this TV; options like delete, edit, etc

#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.


And 2 other "normal" UIViewControllers as the 2 tabs. The title does not get set and a NSLog would not fire.

What am I doing wrong?

Thanks! Erik

let me start with the code:

    var lat1:CLLocationDegrees = 50.102760 

    var lat2:CLLocationDegrees = -26.135170


    var lat191:CLLocationDegrees = 60.289139

    var LocCount = 191

    for var iLat = 3; iLat == LocCount; ++iLat{
            AirportLat.append("lat" + iLat)    

What i try is go to count up the name of the var that should be appended to my array is there a way to do this?

I have an array of dictionaries and I want to find the dictionary with desired value for key "guid". Can not get it with this code:

NSPredicate *filter = [NSPredicate predicateWithFormat:@"guid = %@", key];
NSArray *filteredContacts = [selectedValue filteredArrayUsingPredicate:filter];

Today I cannot submit the binary to App Store, with the error "Invalid binary, the binary is missing architectures[arm64]".

But in "build settings"->"architectures", it does have arm64.

The previous version can be submitted successfully, and I haven't modified project settings.

enter image description here

This question already has an answer here:

Please say that 'code rots' if you don't clean it. What does that mean?

Obviously code is text, not an organism that can change itself. So why does code 'rot' if you don't touch it? What makes it 'rot' and what does it actually mean?

Please explain, examples would be welcome.